From de3210c2e71af791da137ac47107fa8e29613d41 Mon Sep 17 00:00:00 2001 From: hkoertge Date: Fri, 12 May 2023 15:35:15 +0200 Subject: [PATCH 001/237] updated find_packages() to find_namespace_packages() closes #535 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0c3ff1377..196ecf5ba 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # 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. -from setuptools import find_packages +from setuptools import find_namespace_packages from setuptools import setup import re @@ -49,7 +49,7 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "python-igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_packages(), + packages=find_namespace_packages(), include_package_data=True, classifiers=classifiers ) From c85131d557d7a13f82c6ae73f3ebfef6fcde4210 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Wed, 6 Sep 2023 14:18:19 +0200 Subject: [PATCH 002/237] implementation of heat consumer as unit that combines hydraulic and thermal properties of a consumer (mass flow, heat extraction, temperature difference and return temperature) Note: the model currently only works with set mass flow and heat extraction, as the other modes require a more dedicated simulation wrt. the update of fluid properties between heat transfer iterations and a feedback of heat transfer results to hydraulics --- .../heat_consumer_component.py | 246 ++++++++++++++++++ pandapipes/create.py | 69 +++++ .../api/test_components/test_heat_consumer.py | 45 ++++ 3 files changed, 360 insertions(+) create mode 100644 pandapipes/component_models/heat_consumer_component.py create mode 100644 pandapipes/test/api/test_components/test_heat_consumer.py diff --git a/pandapipes/component_models/heat_consumer_component.py b/pandapipes/component_models/heat_consumer_component.py new file mode 100644 index 000000000..6a9510b62 --- /dev/null +++ b/pandapipes/component_models/heat_consumer_component.py @@ -0,0 +1,246 @@ +# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# and Energy System Technology (IEE), 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 import get_fluid, \ + BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup +from pandapipes.component_models.junction_component import Junction +from pandapipes.idx_branch import D, AREA, VINIT, ALPHA, QEXT, \ + RHO, TEXT, JAC_DERIV_DP1, JAC_DERIV_DV, JAC_DERIV_DP, LOAD_VEC_BRANCHES, TL +from pandapipes.pf.result_extraction import extract_branch_results_without_internals + + +class HeatConsumer(BranchWZeroLengthComponent): + """ + + """ + # columns for internal array + MASS = 0 + QEXT = 1 + DELTAT = 2 + TRETURN = 3 + MODE = 4 + + internal_cols = 5 + + # numbering of given parameters (for mdot, qext, deltat, treturn) + MF = 0 + QE = 1 + DT = 2 + TR = 3 + + # heat consumer modes (sum of combinations of given parameters) + MF_QE = 1 + MF_DT = 2 + MF_TR = 4 + QE_DT = 3 + QE_TR = 5 + + @classmethod + def table_name(cls): + return "heat_consumer" + + @classmethod + def get_connected_node_type(cls): + return Junction + + @classmethod + def from_to_node_cols(cls): + return "from_junction", "to_junction" + + @classmethod + def active_identifier(cls): + return "in_service" + + @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. + """ + hs_pit = super().create_pit_branch_entries(net, branch_pit) + hs_pit[:, D] = net[cls.table_name()].diameter_m.values + hs_pit[:, AREA] = hs_pit[:, D] ** 2 * np.pi / 4 + hs_pit[:, VINIT] = (net[cls.table_name()].controlled_mdot_kg_per_s.values / + (hs_pit[:, AREA] * hs_pit[:, RHO])) + hs_pit[:, ALPHA] = 0 + hs_pit[:, QEXT] = net[cls.table_name()].qext_w.values + hs_pit[:, TEXT] = 293.15 + return hs_pit + + @classmethod + def create_component_array(cls, net, component_pits): + """ + Function which creates an internal array of the component in analogy to the pit, but with + component specific entries, that are not needed in the pit. + + :param net: The pandapipes network + :type net: pandapipesNet + :param component_pits: dictionary of component specific arrays + :type component_pits: dict + :return: + :rtype: + """ + tbl = net[cls.table_name()] + consumer_array = np.zeros(shape=(len(tbl), cls.internal_cols), dtype=np.float64) + consumer_array[:, cls.MASS] = tbl.controlled_mdot_kg_per_s.values + consumer_array[:, cls.QEXT] = tbl.qext_w.values + consumer_array[:, cls.DELTAT] = tbl.deltat_k.values + consumer_array[:, cls.TRETURN] = tbl.treturn_k.values + mf = ~np.isnan(consumer_array[:, cls.MASS]) + qe = ~np.isnan(consumer_array[:, cls.QEXT]) + dt = ~np.isnan(consumer_array[:, cls.DELTAT]) + tr = ~np.isnan(consumer_array[:, cls.TRETURN]) + consumer_array[:, cls.MODE] = np.sum([mf, qe, dt, tr], axis=0) + component_pits[cls.table_name()] = consumer_array + + @classmethod + def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): + """ + Perform adaptions to the branch pit after the derivatives have been calculated globally. + + :param net: The pandapipes network containing all relevant info + :type net: pandapipesNet + :param branch_pit: The branch internal array + :type branch_pit: np.ndarray + :param node_pit: The node internal array + :type node_pit: np.ndarray + :param idx_lookups: Lookup for the relevant indices in the pit + :type idx_lookups: dict + :param options: Options for the pipeflow + :type options: dict + :return: No Output. + :rtype: None + """ + # set all pressure derivatives to 0 and velocity to 1; load vector must be 0, as no change + # of velocity is allowed during the pipeflow iteration + f, t = idx_lookups[cls.table_name()] + fc_branch_pit = branch_pit[f:t, :] + fc_array = get_component_array(net, cls.table_name()) + # TODO: this is more precise, but slower: + # np.isin(fc_array[:, cls.MODE], [cls.MF_QE, cls.MF_DT, cls.MF_TR]) + mdot_controlled = ~np.isnan(fc_array[:, cls.MASS]) + fc_branch_pit[mdot_controlled, JAC_DERIV_DP] = 0 + fc_branch_pit[mdot_controlled, JAC_DERIV_DP1] = 0 + fc_branch_pit[mdot_controlled, JAC_DERIV_DV] = 1 + fc_branch_pit[mdot_controlled, LOAD_VEC_BRANCHES] = 0 + + # @classmethod + # def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + # f, t = idx_lookups[cls.table_name()] + # hs_pit = branch_pit[f:t, :] + # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) + # hs_pit[mask_t_return, TINIT_OUT] = hs_pit[mask_t_return, TINIT_OUT] - hs_pit[mask_t_return, DELTAT] + # + # + # @classmethod + # def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + # """ + # + # :param net: + # :type net: + # :param branch_component_pit: + # :type branch_component_pit: + # :param node_pit: + # :type node_pit: + # :return: + # :rtype: + # """ + # # -(rho * area * cp * v_init * (-t_init_i + t_init_i1 - tl) + # # - alpha * (t_amb - t_m) * length + qext) + # + # f, t = idx_lookups[cls.table_name()] + # hs_pit = branch_pit[f:t, :] + # from_nodes = hs_pit[:, FROM_NODE_T].astype(np.int32) + # + # mask_qext = ~np.isnan(hs_pit[:, QEXT]) + # mask_deltat = ~np.isnan(hs_pit[:, DELTAT]) + # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) + # mask_mass = ~np.isnan(hs_pit[:, MASS]) + # hs_pit[mask_t_return | mask_deltat, JAC_DERIV_DT1] = 0 + + @classmethod + def get_component_input(cls): + """ + + Get component input. + + :return: + :rtype: + """ + return [("name", dtype(object)), + ("from_junction", "u4"), + ("to_junction", "u4"), + ("controlled_mdot_kg_per_s", "f8"), + ("qext_w", 'f8'), + ("deltat_k", 'f8'), + ("t_retrun_k", 'f8'), + ("diameter_m", "f8"), + ("control_active", "bool"), + ("in_service", 'bool'), + ("type", dtype(object))] + + @classmethod + def get_result_table(cls, net): + """ + + Gets the result table. + + :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 + + @classmethod + def extract_results(cls, net, options, branch_results, mode): + """ + + :param net: + :type net: + :param options: + :type options: + :param branch_results: + :type branch_results: + :param mode: + :type mode: + :return: + :rtype: + """ + required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) + + extract_branch_results_without_internals(net, branch_results, required_results_hyd, + required_results_ht, cls.table_name(), mode) + + @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 diff --git a/pandapipes/create.py b/pandapipes/create.py index ba4591a16..a292b22a5 100644 --- a/pandapipes/create.py +++ b/pandapipes/create.py @@ -13,6 +13,7 @@ Compressor, MassStorage from pandapipes.component_models.component_toolbox import add_new_component from pandapipes.component_models.flow_control_component import FlowControlComponent +from pandapipes.component_models.heat_consumer_component import HeatConsumer from pandapipes.pandapipes_net import pandapipesNet, get_basic_net_entries, add_default_components from pandapipes.properties import call_lib from pandapipes.properties.fluids import Fluid, _add_fluid_to_net @@ -1019,6 +1020,74 @@ def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_ return index +def create_heat_consumer(net, from_junction, to_junction, diameter_m, controlled_mdot_kg_per_s=None, + qext_w=None, deltat_k=None, treturn_k=None, name=None, index=None, + in_service=True, type="heat_consumer", **kwargs): + """ + Creates a heat consumer element in net["heat_consumer"] from heat consumer parameters. + + :param net: The net for which this heat consumer should be created + :type net: + :param from_junction: ID of the junction on one side which the heat consumer will be connected \ + with + :type from_junction: int + :param to_junction: ID of the junction on the other side which the heat consumer will be \ + connected with + :type to_junction: int + :param diameter_m: The heat consumer inner diameter in [m] - only for result calculation + :type diameter_m: float + :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. + :type controlled_mdot_kg_per_s: float, default None + :param qext_w: External heat flux in [W]. If positive, heat is extracted from the network. If \ + negative, heat is being fed into the network from a heat source. + :type qext_w: float, default None + :param deltat_k: Temperature difference set point between flow and return in [K]. + :type deltat_k: float, default None + :param treturn_k: Return temperature set point in [K]. + :type treturn_k: float, default None + :param name: Name of the heat consumer element + :type name: str, default None + :param index: Force a specified ID if it is available. If None, the index one higher than the\ + highest already existing index is selected. + :type index: int, default None + :param in_service: True if heat consumer is in service or False if it is out of service + :type in_service: bool, default True + :param type: Currently not used - possibility to specify a certain type of heat consumer + :type type: str, default "heat_consumer" + :param kwargs: Additional keyword arguments will be added as further columns to the \ + net["heat_consumer"] table + :type kwargs: dict + :return: index - The unique ID of the created heat consumer + :rtype: int + + :Example: + >>> create_heat_consumer(net,from_junction=0, to_junction=1, diameter_m=40e-3, qext_w=2000) + """ + if deltat_k is not None or treturn_k is not None: + raise NotImplementedError("The models for consumers with fixed temperature difference or " + "fixed return temperature are not implemented yet.") + if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) + + (treturn_k is None) !=2): + raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") + if deltat_k is not None and treturn_k is not None: + raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " + r"flow temperature is independent of the heat consumer model.") + + add_new_component(net, HeatConsumer) + + index = _get_index_with_check(net, "heat_consumer", index, "heat consumer") + _check_branch(net, "Heat consumer", index, from_junction, to_junction) + + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, + "diameter_m": diameter_m, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, + "qext_w": qext_w, "deltat_k": deltat_k, "treturn_k": treturn_k, + "in_service": bool(in_service), "type": type} + _set_entries(net, "heat_consumer", index, **v, **kwargs) + + return index + + def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, type="junction", geodata=None, **kwargs): """ diff --git a/pandapipes/test/api/test_components/test_heat_consumer.py b/pandapipes/test/api/test_components/test_heat_consumer.py new file mode 100644 index 000000000..95a969f9d --- /dev/null +++ b/pandapipes/test/api/test_components/test_heat_consumer.py @@ -0,0 +1,45 @@ +# 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 copy + +import pandapipes +import pandas as pd +import numpy as np + + +def test_heat_consumer_equivalence(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + + mdot = [3, 2] + qext = [150000, 75000] + + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, + system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters( + net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, + system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 + ) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + + net2 = copy.deepcopy(net) + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + qext_w=qext[1]) + pandapipes.pipeflow(net, mode="all") + + j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) + pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, mdot, diameter_m=0.1022) + pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, qext) + pandapipes.pipeflow(net2, mode="all") + + assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) + + +if __name__ == '__main__': + pd.set_option("display.width", 1000) + pd.set_option("display.max_columns", 45) + pd.set_option("display.max_colwidth", 100) + pd.set_option("display.max_rows", 200) From 8f2c39f0b49b66ec9f240af26eb7c6bb42284add Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Wed, 6 Sep 2023 15:50:05 +0200 Subject: [PATCH 003/237] correction in heat consumer input parameters --- pandapipes/component_models/heat_consumer_component.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandapipes/component_models/heat_consumer_component.py b/pandapipes/component_models/heat_consumer_component.py index 6a9510b62..62169ecb1 100644 --- a/pandapipes/component_models/heat_consumer_component.py +++ b/pandapipes/component_models/heat_consumer_component.py @@ -181,9 +181,8 @@ def get_component_input(cls): ("controlled_mdot_kg_per_s", "f8"), ("qext_w", 'f8'), ("deltat_k", 'f8'), - ("t_retrun_k", 'f8'), + ("treturn_k", 'f8'), ("diameter_m", "f8"), - ("control_active", "bool"), ("in_service", 'bool'), ("type", dtype(object))] From c0ac8a5447390eb0e2caafc1913a8a756d1e9e32 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 3 Nov 2023 09:52:38 +0100 Subject: [PATCH 004/237] made list of liquids and gases global in fluids.py --- pandapipes/properties/fluids.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index 9721fa3cd..fd9a275aa 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -18,6 +18,9 @@ logger = logging.getLogger(__name__) +_LIQUIDS = ["water"] +_GASES = ["air", "lgas", "hgas", "hydrogen", "methane", "biomethane_pure", "biomethane_treated"] + class Fluid(JSONSerializableClass): """ @@ -668,17 +671,14 @@ def linear_property(prop): return FluidPropertyLinear.from_path( os.path.join(pp_dir, "properties", fluid_name, prop + ".txt")) - liquids = ["water"] - gases = ["air", "lgas", "hgas", "hydrogen", "methane", "biomethane_pure", "biomethane_treated"] - if fluid_name == "natural_gas": logger.error("'natural_gas' is ambigious. Please choose 'hgas' or 'lgas' " "(high- or low calorific natural gas)") - if fluid_name not in liquids and fluid_name not in gases: + if fluid_name not in _LIQUIDS and fluid_name not in _GASES: raise AttributeError("Fluid '%s' not found in the fluid library. It might not be " "implemented yet." % fluid_name) - phase = "liquid" if fluid_name in liquids else "gas" + phase = "liquid" if fluid_name in _LIQUIDS else "gas" density = interextra_property("density") viscosity = interextra_property("viscosity") From bab5c14f935c100c3009a16dcf46299bb6c31e11 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 3 Nov 2023 10:42:02 +0100 Subject: [PATCH 005/237] corrections in fluid library to make call_lib pass again - adapted wrong files for new biomethane properties - added lhv and hhv with exception in case file was not found, as these properties are not absolutely necessary --- .../biomethane_pure/lower_heating_value.txt | 1 - .../biomethane_treated/compressibility.txt | 2 +- .../biomethane_treated/heat_capacity.txt | 2 +- .../lower_heating_value.txt | 1 - pandapipes/properties/fluids.py | 34 +++++++++---------- 5 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 pandapipes/properties/biomethane_pure/lower_heating_value.txt delete mode 100644 pandapipes/properties/biomethane_treated/lower_heating_value.txt diff --git a/pandapipes/properties/biomethane_pure/lower_heating_value.txt b/pandapipes/properties/biomethane_pure/lower_heating_value.txt deleted file mode 100644 index e7b41c8d4..000000000 --- a/pandapipes/properties/biomethane_pure/lower_heating_value.txt +++ /dev/null @@ -1 +0,0 @@ -# lower heating value in kWh/kg (at normal conditions) diff --git a/pandapipes/properties/biomethane_treated/compressibility.txt b/pandapipes/properties/biomethane_treated/compressibility.txt index 7ebaa69ce..dbb50a0a5 100644 --- a/pandapipes/properties/biomethane_treated/compressibility.txt +++ b/pandapipes/properties/biomethane_treated/compressibility.txt @@ -1,3 +1,3 @@ # source: linear approximation based on CoolProp (http://www.coolprop.org/) # slope in 1/bar, offset for linear property --0.0024789428559189412, 0.9962776221466679 \ No newline at end of file +-0.0024789428559189412 0.9962776221466679 \ No newline at end of file diff --git a/pandapipes/properties/biomethane_treated/heat_capacity.txt b/pandapipes/properties/biomethane_treated/heat_capacity.txt index f9f78e48d..ec06044fc 100644 --- a/pandapipes/properties/biomethane_treated/heat_capacity.txt +++ b/pandapipes/properties/biomethane_treated/heat_capacity.txt @@ -1,6 +1,6 @@ #source CoolProp (http://www.coolprop.org/) # temperature in Kelvin, isobaric heat capacity in J/(kg K) -263.151976.8823234072695 +263.15 1976.8823234072695 265.15 1980.6134982832095 267.15 1984.416050463013 269.15 1988.2894370033634 diff --git a/pandapipes/properties/biomethane_treated/lower_heating_value.txt b/pandapipes/properties/biomethane_treated/lower_heating_value.txt deleted file mode 100644 index e7b41c8d4..000000000 --- a/pandapipes/properties/biomethane_treated/lower_heating_value.txt +++ /dev/null @@ -1 +0,0 @@ -# lower heating value in kWh/kg (at normal conditions) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index fd9a275aa..5d35b0f36 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -680,24 +680,22 @@ def linear_property(prop): phase = "liquid" if fluid_name in _LIQUIDS else "gas" - density = interextra_property("density") - viscosity = interextra_property("viscosity") - heat_capacity = interextra_property("heat_capacity") - molar_mass = constant_property("molar_mass") - der_compr = constant_property("der_compressibility") - compr = linear_property("compressibility") - - if (phase == 'gas') & (fluid_name != 'air'): - lhv = constant_property("lower_heating_value") - hhv = constant_property("higher_heating_value") - - return Fluid(fluid_name, phase, density=density, viscosity=viscosity, - heat_capacity=heat_capacity, molar_mass=molar_mass, - compressibility=compr, der_compressibility=der_compr, lhv=lhv, hhv=hhv) - else: - return Fluid(fluid_name, phase, density=density, viscosity=viscosity, - heat_capacity=heat_capacity, molar_mass=molar_mass, compressibility=compr, - der_compressibility=der_compr) + properties = dict() + properties["density"] = interextra_property("density") + properties["viscosity"] = interextra_property("viscosity") + properties["heat_capacity"] = interextra_property("heat_capacity") + properties["molar_mass"] = constant_property("molar_mass") + properties["der_compressibility"] = constant_property("der_compressibility") + properties["compressibility"] = linear_property("compressibility") + + if phase == 'gas': + for entry, name in [("lhv", "lower_heating_value"), ("hhv", "higher_heating_value")]: + try: + properties[entry] = constant_property(name) + except FileNotFoundError: + pass + + return Fluid(fluid_name, phase, **properties) def get_fluid(net): From b82f5020c1227405e0e522481e683dff321701dc Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 3 Nov 2023 15:50:26 +0100 Subject: [PATCH 006/237] take only files from pandapipes folder --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ba1a37a33..4608f4c53 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,8 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(), + packages=find_namespace_packages(where="pandapipes"), + package_dir={"": "pandapipes"}, include_package_data=True, classifiers=classifiers ) From b1ee8dbdc4753c7becffdc3febcaa81e5dc2146c Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 20 Nov 2023 12:26:21 +0100 Subject: [PATCH 007/237] added warning when not finding LHV / HHV in fluid lib --- pandapipes/properties/fluids.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandapipes/properties/fluids.py b/pandapipes/properties/fluids.py index 5d35b0f36..7917b2e1d 100644 --- a/pandapipes/properties/fluids.py +++ b/pandapipes/properties/fluids.py @@ -693,7 +693,10 @@ def linear_property(prop): try: properties[entry] = constant_property(name) except FileNotFoundError: - pass + logger.warning( + f"Unable to find {' '.join([n.capitalize() for n in name.split('_')])} for " + f"{fluid_name}" + ) return Fluid(fluid_name, phase, **properties) From 8a9d614ed7d4565064cbb910518f320e35fd2a6d Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 20 Nov 2023 12:48:27 +0100 Subject: [PATCH 008/237] small fixes for graph creation wrt pressure circ_pumps and for stanet converter (wrong keyword) --- pandapipes/converter/stanet/table_creation.py | 2 +- pandapipes/topology/create_graph.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandapipes/converter/stanet/table_creation.py b/pandapipes/converter/stanet/table_creation.py index 553a0c3f4..ae80a264f 100644 --- a/pandapipes/converter/stanet/table_creation.py +++ b/pandapipes/converter/stanet/table_creation.py @@ -631,7 +631,7 @@ def create_heat_exchangers_stanet(net, stored_data, index_mapping, add_layers, a # TODO: there is no qext given!!! pandapipes.create_heat_exchanger( net, node_mapping[from_stanet_nr], node_mapping[to_stanet_nr], qext_w=qext, - diameter_m=float(row.DM / 1000), loss_coefficient=row.ZETA, std_type=row.ROHRTYP, + diameter_m=float(row.DM / 1000), loss_coefficient=row.ZETA, in_service=bool(row.ISACTIVE), name="heat_exchanger_%s_%s" % (row.ANFNAM, row.ENDNAM), stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=row.VM, stanet_active=bool(row.ISACTIVE), **add_info diff --git a/pandapipes/topology/create_graph.py b/pandapipes/topology/create_graph.py index 529fa7f89..96b0a3132 100644 --- a/pandapipes/topology/create_graph.py +++ b/pandapipes/topology/create_graph.py @@ -113,7 +113,7 @@ def create_nxgraph(net, include_pipes=True, respect_status_pipes=True, loc = locals() branch_params.update({"%s_%s" % (par, bc): loc.get("%s_%s" % (par, bc)) for par in branch_kw for bc in ["pipes", "valves", "pumps", "press_controls", - "mass_circ_pumps", "press_circ_pumps", "valve_pipes", + "mass_circ_pumps", "pressure_circ_pumps", "valve_pipes", "flow_controls"]}) for comp in net.component_list: From c425cb6679aaf6835e314af60c7dea66c95eec1b Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 4 Dec 2023 10:47:07 +0100 Subject: [PATCH 009/237] added option to guess slider valve types; some small adaptions --- .../converter/stanet/preparing_steps.py | 47 +++-- .../converter/stanet/stanet2pandapipes.py | 8 +- pandapipes/converter/stanet/table_creation.py | 187 +++++++++++------- 3 files changed, 146 insertions(+), 96 deletions(-) diff --git a/pandapipes/converter/stanet/preparing_steps.py b/pandapipes/converter/stanet/preparing_steps.py index 0050b643a..91e8b5b5e 100644 --- a/pandapipes/converter/stanet/preparing_steps.py +++ b/pandapipes/converter/stanet/preparing_steps.py @@ -25,6 +25,28 @@ logger = logging.getLogger(__name__) +DEFAULT_STANET_KEYWORDS = { + "pipes": ['REM Leitungsdaten'], + "house_pipes": ['REM HA Leitungsdaten'], + "nodes": ['REM Knotendaten'], + "house_nodes": ["REM HA Knotendaten"], + "valves": ['REM Ventiledaten'], + "pumps_gas": ['REM Kompressorendaten'], + "pumps_water": ['REM Pumpendaten'], + "net_parameters": ['REM Netzparameterdaten'], + "houses": ["REM Hausdaten"], + "house_connections": ["REM HA Verbindungsdaten"], + "meters": ["REM HA Zählerdaten"], + "controllers": ["REM Reglerdaten"], + "slider_valves": ["REM Schieberdaten"], + "inflexion_points": ["REM Knickpunktdaten"], + "heat_exchangers": ["REM Wärmetauscherdaten"], + "customers": ["REM Abnehmerdaten"], + "house_inflexion_points": ["REM HA Knickpunktdaten"], + "layers": ["REM Layerdaten"] +} + + def get_stanet_raw_data(stanet_path, read_options=None, add_layers=True, return_line_info=False, keywords=None): """ @@ -52,24 +74,7 @@ def get_stanet_raw_data(stanet_path, read_options=None, add_layers=True, return_ # 4th line: STANET internal header of table (this is the first line to convert to pandas # dataframe and return to the converter) # everything until the next empty line will be added to the dataframe - keywords = {"pipes": ['REM Leitungsdaten'], - "house_pipes": ['REM HA Leitungsdaten'], - "nodes": ['REM Knotendaten'], - "house_nodes": ["REM HA Knotendaten"], - "valves": ['REM Ventiledaten'], - "pumps_gas": ['REM Kompressorendaten'], - "pumps_water": ['REM Pumpendaten'], - "net_parameters": ['REM Netzparameterdaten'], - "houses": ["REM Hausdaten"], - "house_connections": ["REM HA Verbindungsdaten"], - "meters": ["REM HA Zählerdaten"], - "controllers": ["REM Reglerdaten"], - "slider_valves": ["REM Schieberdaten"], - "inflexion_points": ["REM Knickpunktdaten"], - "heat_exchangers": ["REM Wärmetauscherdaten"], - "customers": ["REM Abnehmerdaten"], - "house_inflexion_points": ["REM HA Knickpunktdaten"], - "layers": ["REM Layerdaten"]} + keywords = DEFAULT_STANET_KEYWORDS stored_data = dict() logger.info("Reading STANET csv-file.") @@ -230,9 +235,9 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe coord = "x" if is_x else "y" locat = "from" if is_start else "to" run = 0 if is_x else 2 - run += 0 if is_start else 1 + run += 1 - int(is_start) pipe_name = coord_names[run] - node_nr = node_cols[0] if is_start else node_cols[1] + node_nr = node_cols[1 - int(is_start)] node_val = node_geo.loc[pipe_data.loc[pipes_to_check, node_nr].values, node_name].values if pipe_name not in pipe_data.columns: @@ -273,7 +278,7 @@ def adapt_pipe_data(stored_data, pipe_data, coord_names, use_clients): # the following code is just a check whether pipe and node geodata fit together # in case of deviations, the pipe geodata is adapted on the basis of the node geodata - pipe_rec = pipe_data.RECNO.values + pipe_rec = pipe_data.index.values for is_x, is_start in product([True, False], [True, False]): current_index_range = indices[0] if is_start else indices[1] current_pipe_nums = pipe_rec[current_index_range.values] diff --git a/pandapipes/converter/stanet/stanet2pandapipes.py b/pandapipes/converter/stanet/stanet2pandapipes.py index a0a4f6875..ed644f9f9 100644 --- a/pandapipes/converter/stanet/stanet2pandapipes.py +++ b/pandapipes/converter/stanet/stanet2pandapipes.py @@ -31,7 +31,8 @@ # - maybe it will be necessary to remove deleted data from the STANET tables, otherwise they # might be inserted into the pandapipes net erroneously def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connections=True, - stanet_like_valves=False, read_options=None, add_layers=True, **kwargs): + stanet_like_valves=False, read_options=None, add_layers=True, + guess_slider_valve_types=False, **kwargs): """Converts STANET csv-file to pandapipesNet. :param stanet_path: path to csv-file exported from STANET @@ -50,6 +51,9 @@ def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connec :param add_layers: If True, adds information on layers of different components if provided by \ STANET :type add_layers: bool, default True + :param guess_slider_valve_types: If set to True, the slider valve status (opened / closed) is \ + guessed based on the logic "even number = opened; odd number = closed". + :type guess_slider_valve_types: bool, default False :return: net :rtype: pandapipesNet """ @@ -99,7 +103,7 @@ def stanet_to_pandapipes(stanet_path, name="net", remove_unused_household_connec # pandapipes create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_like_valves, add_layers) - create_slider_valves(net, stored_data, index_mapping, add_layers) + create_slider_valves(net, stored_data, index_mapping, add_layers, guess_slider_valve_types) if "pumps_water" in stored_data: create_pumps(net, stored_data['pumps_water'], index_mapping, add_layers) diff --git a/pandapipes/converter/stanet/table_creation.py b/pandapipes/converter/stanet/table_creation.py index 553a0c3f4..ab974d142 100644 --- a/pandapipes/converter/stanet/table_creation.py +++ b/pandapipes/converter/stanet/table_creation.py @@ -65,8 +65,9 @@ def create_junctions_from_nodes(net, stored_data, net_params, index_mapping, add add_info = {"stanet_id": node_table.STANETID.astype(str).values if "STANETID" in node_table.columns else knams, "p_stanet": node_table.PRECH.values.astype(np.float64), - "stanet_valid": ~node_table.CALCBAD.values.astype(np.bool_), - "t_stanet": node_table.TEMP.values.astype(np.float64)} + "stanet_valid": ~node_table.CALCBAD.values.astype(np.bool_)} + if "TEMP" in node_table.columns: + add_info["t_stanet"] = node_table.TEMP.values.astype(np.float64) if hasattr(node_table, "KFAK"): add_info["K_stanet"] = node_table.KFAK.values.astype(np.float64) if add_layers: @@ -173,62 +174,88 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li ) -def create_slider_valves(net, stored_data, index_mapping, add_layers): +def create_slider_valves(net, stored_data, index_mapping, add_layers, + guess_opened_from_types=False): """ Creates pandapipes slider valves from STANET data. - :param net: - :type net: - :param stored_data: - :type stored_data: - :param index_mapping: - :type index_mapping: - :param add_layers: - :type add_layers: - :return: - :rtype: + + :param net: pandapipes net to which to add slider valves + :type net: pandapipesNet + :param stored_data: dictionary of STANET element tables + :type stored_data: dict + :param index_mapping: dictionary of mappings between STANET and pandapipes indices + :type index_mapping: dict + :param add_layers: if True, the layer info will be added to the slider valve table + :type add_layers: bool + :param guess_opened_from_types: if True, the status of slider valves with unknown types is \ + guessed based on the logic "even type number = opened, odd type number = closed" + :type guess_opened_from_types: bool, default False + :return: No output + :rtype: None """ - if "slider_valves" not in stored_data: + if "slider_valves" not in stored_data and "house_slider_valves" not in stored_data: return logger.info("Creating all slider valves.") - slider_valves = stored_data["slider_valves"] - - # identify all junctions that are connected on each side of the slider valves - svf = index_mapping["slider_valves_from"] - svt = index_mapping["slider_valves_to"] - from_junctions = np.array([svf[sv] for sv in slider_valves.RECNO.values]) - to_junctions = np.array([svt[sv] for sv in slider_valves.RECNO.values]) - - # these types can be converted to normal valves - # --> there are many types of slider valves in STANET, the behavior is not always clear, so - # if you want to convert another type, identify the correct valve behavior in pandapipes - # that matches this type. - opened_sv = [2, 6, 10, 18] - closed_sv = [3, 7, 11, 19] - opened_types = {o: True for o in opened_sv} - opened_types.update({c: False for c in closed_sv}) - sv_types = set(slider_valves.TYP.values.astype(np.int32)) - if len(sv_types - set(opened_types.keys())): - raise UserWarning("The slider valve types %s cannot be converted." - % (sv_types - set(opened_types.keys()))) - - # create all slider valves --> most important are the opened and loss_coefficient entries - valve_system = slider_valves.CLIENTTYP.replace(CLIENT_TYPES_OF_PIPES).values - add_info = dict() - if add_layers: - add_info["stanet_layer"] = slider_valves.LAYER.values.astype(str) - # account for sliders with diameter 0 m - if any(slider_valves.DM == 0): - logger.warning(f"{sum(slider_valves.DM == 0)} sliders have a inner diameter of 0 m! " - f"The diameter will be set to 1 m.") - slider_valves.DM[slider_valves.DM == 0] = 1e3 - pandapipes.create_valves( - net, from_junctions, to_junctions, slider_valves.DM.values / 1000, - opened=slider_valves.TYP.astype(np.int32).replace(opened_types).values, - loss_coefficient=slider_valves.ZETA.values, name=slider_valves.STANETID.values, - type="slider_valve_" + valve_system, stanet_nr=slider_valves.RECNO.values.astype(np.int32), - stanet_id=slider_valves.STANETID.values.astype(str), stanet_system=valve_system, - stanet_active=slider_valves.ISACTIVE.values.astype(np.bool_), **add_info - ) + + for tbl_name in ("slider_valves", "house_slider_valves"): + if tbl_name not in stored_data: + continue + slider_valves = stored_data[tbl_name] + + # identify all junctions that are connected on each side of the slider valves + svf = index_mapping["slider_valves_from"] + svt = index_mapping["slider_valves_to"] + from_junctions = np.array([svf[sv] for sv in slider_valves.RECNO.values]) + to_junctions = np.array([svt[sv] for sv in slider_valves.RECNO.values]) + + # these types can be converted to normal valves + # --> there are many types of slider valves in STANET, the behavior is not always clear, so + # if you want to convert another type, identify the correct valve behavior in pandapipes + # that matches this type. + opened_sv = [2, 6, 10, 18] + closed_sv = [3, 7, 11, 19] + # TODO: Is it possible that there is always a "CONNECTED" column and it says whether the + # valve is opened or closed? Maybe the type is only used for graphical purpose. + opened_types = {o: True for o in opened_sv} + opened_types.update({c: False for c in closed_sv}) + sv_types = set(slider_valves.TYP.values.astype(np.int32)) + if len(sv_types - set(opened_types.keys())): + if guess_opened_from_types: + logger.warning( + "The slider valve types %s are not (yet) known. Their status (opened/closed) " + "will be guessed based on the logic: even number = opened, odd number = closed." + % (sv_types - set(opened_types.keys())) + ) + opened_types.update( + {t: bool(t % 2 + 1) for t in sv_types - set(opened_types.keys())} + ) + else: + raise UserWarning("The slider valve types %s cannot be converted." + % (sv_types - set(opened_types.keys()))) + + # create all slider valves --> most important are the opened and loss_coefficient entries + valve_system = slider_valves.CLIENTTYP.replace(CLIENT_TYPES_OF_PIPES).values + add_info = dict() + if add_layers: + add_info["stanet_layer"] = slider_valves.LAYER.values.astype(str) + # account for sliders with diameter 0 m + if "DM" not in slider_valves.columns: + logger.warning(f"The table {tbl_name} does not contain the slider valve inner diameter!" + f"The diameter will be set to 1 m.") + slider_valves["DM"] = 1e3 + if any(slider_valves.DM == 0): + logger.warning(f"{sum(slider_valves.DM == 0)} sliders have an inner diameter of 0 m! " + f"The diameter will be set to 1 m.") + slider_valves.DM[slider_valves.DM == 0] = 1e3 + pandapipes.create_valves( + net, from_junctions, to_junctions, slider_valves.DM.values / 1000, + opened=slider_valves.TYP.astype(np.int32).replace(opened_types).values, + loss_coefficient=slider_valves.ZETA.values, name=slider_valves.STANETID.values, + type="slider_valve_" + valve_system, + stanet_nr=slider_valves.RECNO.values.astype(np.int32), + stanet_id=slider_valves.STANETID.values.astype(str), stanet_system=valve_system, + stanet_active=slider_valves.ISACTIVE.values.astype(np.bool_), **add_info + ) # noinspection PyTypeChecker @@ -317,7 +344,7 @@ def create_control_components(net, stored_data, index_mapping, net_params, add_l control_active = (control_table.AKTIV.values == "J").astype(np.bool_) if consider_controlled: - control_active &= fully_open + control_active &= ~fully_open in_service = control_table.ISACTIVE.values.astype(np.bool_) if consider_controlled: in_service &= ~(control_table.ZU.values == "J") @@ -398,7 +425,7 @@ def get_connection_types(connection_table): :return: :rtype: """ - extend_from_to = ["slider_valves"] + extend_from_to = ["slider_valves", "house_slider_valves"] connection_types = list(chain.from_iterable([ [(ct, ct)] if ct not in extend_from_to else [(ct, ct + "_from"), (ct, ct + "_to")] for ct in set(connection_table.type) @@ -432,6 +459,8 @@ def create_junctions_from_connections(net, connection_table, net_params, index_m extend_from_to, connection_types = get_connection_types(connection_table) for con_type, node_type in connection_types: cons = connection_table.loc[connection_table.type == con_type] + if cons.empty: + continue stanet_ids = cons.STANETID.astype(str).values stanet_nrs = cons.RECNO.astype(np.int32).values p_stanet = cons.PRECH.astype(np.float64).values if houses_in_calculation else np.NaN @@ -566,11 +595,14 @@ def create_geodata_sections(row): text_k = 293 if "TU" in pipes.columns: text_k = pipes.TU.values.astype(np.float64) + 273.15 + alpha = 0 + if "WDZAHL" in pipes.columns: + alpha = pipes.WDZAHL.values.astype(np.float64) pandapipes.create_pipes_from_parameters( net, pipe_sections.fj.values, pipe_sections.tj.values, pipe_sections.length.values / 1000, pipes.DM.values / 1000, pipes.RAU.values, pipes.ZETA.values, type="main_pipe", stanet_std_type=pipes.ROHRTYP.values, in_service=pipes.ISACTIVE.values, text_k=text_k, - alpha_w_per_m2k=pipes.WDZAHL.values.astype(np.float64), + alpha_w_per_m2k=alpha, name=["pipe_%s_%s_%s" % (nf, nt, sec) for nf, nt, sec in zip( pipes.ANFNAM.values, pipes.ENDNAM.values, pipe_sections.section_no.values)], stanet_nr=pipes.RECNO.values, stanet_id=pipes.STANETID.values, @@ -694,14 +726,16 @@ def create_pipes_from_remaining_pipe_table(net, stored_data, connection_table, i text_k = 293 if "TU" in p_tbl.columns: text_k = p_tbl.TU.values.astype(np.float64) + 273.15 + alpha = 0 + if "WDZAHL" in p_tbl.columns: + alpha = p_tbl.WDZAHL.values.astype(np.float64) pandapipes.create_pipes_from_parameters( net, from_junctions, to_junctions, length_km=p_tbl.RORL.values.astype(np.float64) / 1000, type="main_pipe", diameter_m=p_tbl.DM.values.astype(np.float64) / 1000, loss_coefficient=p_tbl.ZETA.values, stanet_std_type=p_tbl.ROHRTYP.values, k_mm=p_tbl.RAU.values, in_service=p_tbl.ISACTIVE.values.astype(np.bool_), - alpha_w_per_m2k=p_tbl.WDZAHL.values.astype(np.float64), text_k=text_k, name=["pipe_%s_%s" % (anf, end) for anf, end in zip(from_names[valid], to_names[valid])], - stanet_nr=p_tbl.RECNO.values.astype(np.int32), + alpha_w_per_m2k=alpha, text_k=text_k, stanet_nr=p_tbl.RECNO.values.astype(np.int32), stanet_id=p_tbl.STANETID.values.astype(str), v_stanet=p_tbl.VM.values, geodata=geodata, stanet_system=CLIENT_TYPES_OF_PIPES[MAIN_PIPE_TYPE], stanet_active=p_tbl.ISACTIVE.values.astype(np.bool_), @@ -710,7 +744,8 @@ def create_pipes_from_remaining_pipe_table(net, stored_data, connection_table, i ) -def check_connection_client_types(hh_pipes, all_client_types, node_client_types): +def check_connection_client_types(hh_pipes, all_client_types, node_client_types, + fail_on_connection_check=True): # create pipes for household connections (from house to supply pipe), which is a separate table # in the STANET CSV file # --> there are many ways how household connections can be created in STANET, @@ -725,16 +760,20 @@ def check_connection_client_types(hh_pipes, all_client_types, node_client_types) clientnodetype = hh_pipes.CLIENTTYP.isin(node_client_types) client2nodetype = hh_pipes.CLIENT2TYP.isin(node_client_types) if not np.all(clientnodetype | client2nodetype): - raise UserWarning( - f"One of the household connection sides must be connected to a node (type {NODE_TYPE} element)\n" - f"or a connection (type {HOUSE_CONNECTION_TYPE} element with ID CON...) " - f"or a house node (type {HOUSE_CONNECTION_TYPE} element). \n" - f"Please check that the input data is correct. \n" - f"Check these CLIENTTYP / CLIENT2TYP: " - f"{set(hh_pipes.loc[~clientnodetype, 'CLIENTTYP'].values) | set(hh_pipes.loc[~client2nodetype, 'CLIENT2TYP'].values)} " - f"in the HA LEI table (max. 10 entries shown): \n " - f"{hh_pipes.loc[~clientnodetype & ~client2nodetype].head(10)}" - ) + not_node_type = (set(hh_pipes.loc[~clientnodetype, 'CLIENTTYP'].values) + | set(hh_pipes.loc[~client2nodetype, 'CLIENT2TYP'].values)) + msg = (f"One of the household connection sides must be connected to a node (type " + f"{NODE_TYPE} element)\n or a connection (type {HOUSE_CONNECTION_TYPE} element with" + f" ID CON...) or a house node (type {HOUSE_CONNECTION_TYPE} element). \n" + f"Please check that the input data is correct. \n" + f"Check these CLIENTTYP / CLIENT2TYP: " + f"{not_node_type} in the HA LEI table (max. 10 entries shown): \n" + f"{hh_pipes.loc[~clientnodetype & ~client2nodetype].head(10)}") + if fail_on_connection_check: + raise UserWarning(msg) + else: + logger.warning(f"{msg} \nWill ignore this error and continue net setup, please check " + f"your network configuration carefully!") return clientnodetype, client2nodetype @@ -1009,16 +1048,18 @@ def create_geodata_sections(row): text_k = 293 if "TU" in hp_data.columns: text_k = hp_data.TU.values.astype(np.float64) + 273.15 + alpha = 0 + if "WDZAHL" in hp_data.columns: + alpha = hp_data.WDZAHL.values.astype(np.float64) pandapipes.create_pipes_from_parameters( net, hp_data.fj.values, hp_data.tj.values, hp_data.length.values / 1000, hp_data.DM.values / 1000, hp_data.RAU.values, hp_data.ZETA.values, type="house_pipe", - stanet_std_type=hp_data.ROHRTYP.values, in_service=hp_data.ISACTIVE.values if houses_in_calculation else False, text_k=text_k, - alpha_w_per_m2k=hp_data.WDZAHL.values.astype(np.float64), + alpha_w_per_m2k=alpha, geodata=hp_data.section_geo.values, name=["pipe_%s_%s_%s" % (nf, nt, sec) for nf, nt, sec in zip( hp_data.CLIENTID.values, hp_data.CLIENT2ID.values, hp_data.section_no.values)], - stanet_nr=hp_data.RECNO.values, stanet_id=hp_data.STANETID.values, - geodata=hp_data.section_geo.values, v_stanet=hp_data.VM.values, + stanet_std_type=hp_data.ROHRTYP.values, stanet_nr=hp_data.RECNO.values, + stanet_id=hp_data.STANETID.values, v_stanet=hp_data.VM.values, stanet_active=hp_data.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info ) From ba81ca0f66bed51a49d2476e6167a0ab1aea047a Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 4 Dec 2023 10:53:06 +0100 Subject: [PATCH 010/237] removed trailing whitespace --- pandapipes/converter/stanet/table_creation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandapipes/converter/stanet/table_creation.py b/pandapipes/converter/stanet/table_creation.py index ae80a264f..1192cf279 100644 --- a/pandapipes/converter/stanet/table_creation.py +++ b/pandapipes/converter/stanet/table_creation.py @@ -631,7 +631,7 @@ def create_heat_exchangers_stanet(net, stored_data, index_mapping, add_layers, a # TODO: there is no qext given!!! pandapipes.create_heat_exchanger( net, node_mapping[from_stanet_nr], node_mapping[to_stanet_nr], qext_w=qext, - diameter_m=float(row.DM / 1000), loss_coefficient=row.ZETA, + diameter_m=float(row.DM / 1000), loss_coefficient=row.ZETA, in_service=bool(row.ISACTIVE), name="heat_exchanger_%s_%s" % (row.ANFNAM, row.ENDNAM), stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=row.VM, stanet_active=bool(row.ISACTIVE), **add_info From 1468b489fc00375bdd0e3be2b0d736cf96483b61 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Mon, 11 Dec 2023 15:47:24 +0100 Subject: [PATCH 011/237] remove changes as part of seperate PR --- pandapipes/test/pipeflow_internals/test_inservice.py | 4 ++-- setup.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandapipes/test/pipeflow_internals/test_inservice.py b/pandapipes/test/pipeflow_internals/test_inservice.py index bec68b475..54acfaf78 100644 --- a/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/pandapipes/test/pipeflow_internals/test_inservice.py @@ -237,8 +237,8 @@ def test_connectivity_hydraulic(create_test_net, use_numba): assert np.all(np.isnan(net.res_pipe.loc[[1, 2, 3], :].values)) assert not np.any(np.isnan(net.res_junction.loc[[0, 1, 3, 4], :].values)) assert not np.any(np.isnan(net.res_pipe.loc[[0, 4], - ["v_mean_m_per_s", "p_from_bar", - "p_to_bar"]].values)) + ["v_mean_m_per_s", "p_from_bar", + "p_to_bar"]].values)) assert not np.any(np.isnan(net.res_sink.loc[[0, 2], "mdot_kg_per_s"].values)) assert np.all(np.isnan(net.res_sink.loc[[1, 3, 4], "mdot_kg_per_s"].values)) diff --git a/setup.py b/setup.py index 4608f4c53..4c22eda53 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # 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. -from setuptools import find_namespace_packages +from setuptools import find_packages from setuptools import setup import re @@ -49,8 +49,7 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(where="pandapipes"), - package_dir={"": "pandapipes"}, + packages=find_packages(), include_package_data=True, classifiers=classifiers ) From ebaa13fdbbd35de43a228c80f94480ea65b7b850 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Mon, 11 Dec 2023 15:51:13 +0100 Subject: [PATCH 012/237] already considered in different PR --- CHANGELOG.rst | 1 - pandapipes/multinet/create_multinet.py | 2 + .../timeseries/run_time_series_multinet.py | 1 + pandapipes/pf/pipeflow_setup.py | 1 - pandapipes/pipeflow.py | 17 ++---- .../test/pipeflow_internals/test_inservice.py | 57 ++++--------------- 6 files changed, 19 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e9f952c5c..58ff9bc6f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,7 +5,6 @@ Change Log ------------------------------- - [ADDED] multiple creation of heat exchanger - [ADDED] support Python 3.11 (now included in test pipeline) -- [ADDED] after the connectivity check, intercept the pipeflow if no more nodes are in-service - [CHANGED] dropped support for Python 3.7 (no longer included in test pipeline) - [CHANGED] connectivity check now separated by hydraulics and heat_transfer calculation, so that also results can differ in some rows (NaN or not) - [CHANGED] dynamic creation of lookups for getting pit as pandas tables diff --git a/pandapipes/multinet/create_multinet.py b/pandapipes/multinet/create_multinet.py index cd74dce9f..4a5352a5c 100644 --- a/pandapipes/multinet/create_multinet.py +++ b/pandapipes/multinet/create_multinet.py @@ -12,6 +12,8 @@ import logging logger = logging.getLogger(__name__) +logger.setLevel(level=logging.WARNING) + def create_empty_multinet(name=""): """ diff --git a/pandapipes/multinet/timeseries/run_time_series_multinet.py b/pandapipes/multinet/timeseries/run_time_series_multinet.py index 1d829c75d..7394a7780 100644 --- a/pandapipes/multinet/timeseries/run_time_series_multinet.py +++ b/pandapipes/multinet/timeseries/run_time_series_multinet.py @@ -19,6 +19,7 @@ import logging as pplog logger = pplog.getLogger(__name__) +logger.setLevel(level=pplog.WARNING) def _call_output_writer(multinet, time_step, pf_converged, ctrl_converged, ts_variables): diff --git a/pandapipes/pf/pipeflow_setup.py b/pandapipes/pf/pipeflow_setup.py index eb63f5f6d..713f05be8 100644 --- a/pandapipes/pf/pipeflow_setup.py +++ b/pandapipes/pf/pipeflow_setup.py @@ -498,7 +498,6 @@ def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): mode = "hydraulics" if hydraulic else "heat_transfer" net["_lookups"]["node_active_" + mode] = nodes_connected net["_lookups"]["branch_active_" + mode] = branches_connected - return node_pit[nodes_connected], branch_pit[branches_connected] def branches_connected_flow(branch_pit): diff --git a/pandapipes/pipeflow.py b/pandapipes/pipeflow.py index 19d16d9ca..aa9f49947 100644 --- a/pandapipes/pipeflow.py +++ b/pandapipes/pipeflow.py @@ -4,6 +4,7 @@ import numpy as np from numpy import linalg +from pandapower.auxiliary import ppException from scipy.sparse.linalg import spsolve from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, VINIT, TOUTINIT, VINIT_T @@ -15,7 +16,6 @@ initialize_pit, reduce_pit, set_user_pf_options, init_all_result_tables, \ identify_active_nodes_branches from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit -from pandapower.auxiliary import ppException try: import pandaplan.core.pplog as logging @@ -70,22 +70,15 @@ def pipeflow(net, sol_vec=None, **kwargs): create_lookups(net) node_pit, branch_pit = initialize_pit(net) - if len(node_pit) == 0: - logger.warning("There are no nodes defined. " - "You need at least one node! " - "Without any nodes, you are not able to conduct a pipeflow!") + if (len(node_pit) == 0) & (len(branch_pit) == 0): + logger.warning("There are no node and branch entries defined. This might mean that your net" + " is empty") return - calculation_mode = get_net_option(net, "mode") calculate_hydraulics = calculation_mode in ["hydraulics", "all"] calculate_heat = calculation_mode in ["heat", "all"] - active_node_pit, active_branch_pit = identify_active_nodes_branches(net, branch_pit, node_pit) - - if (len(active_node_pit) == 0): - logger.warning(" All nodes are out of service. Probably they are not supplied." - " Have you forgotten to define an external grid?") - return + identify_active_nodes_branches(net, branch_pit, node_pit) if calculation_mode == "heat": if not net.user_pf_options["hyd_flag"]: diff --git a/pandapipes/test/pipeflow_internals/test_inservice.py b/pandapipes/test/pipeflow_internals/test_inservice.py index bec68b475..1db306804 100644 --- a/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/pandapipes/test/pipeflow_internals/test_inservice.py @@ -9,8 +9,8 @@ import pandapipes from pandapipes.pf.pipeflow_setup import get_lookup -from pandapipes.pipeflow import PipeflowNotConverged from pandapipes.pipeflow import logger as pf_logger +from pandapipes.pipeflow import PipeflowNotConverged try: import pandaplan.core.pplog as logging @@ -125,29 +125,6 @@ def create_mixed_indexing_grid(): return net -@pytest.fixture -def create_net_wo_external_hydraulic_grid(): - net = pandapipes.create_empty_network("net", add_stdtypes=False) - pandapipes.create_fluid_from_lib(net, "hgas", overwrite=True) - pandapipes.create_junction(net, index=3, pn_bar=16, tfluid_k=283, height_m=0, - name="Junction 3", in_service=True, - type="junction", geodata=(0, 0)) - pandapipes.create_junction(net, index=9, pn_bar=16, tfluid_k=283, height_m=0, - name="Junction 9", in_service=True, - type="junction", geodata=(1, 0)) - pandapipes.create_junction(net, index=10, pn_bar=16, tfluid_k=283, height_m=0, - name="Junction 10", in_service=True, - type="junction", geodata=(2, 0)) - pandapipes.create_pipe_from_parameters(net, 9, 10, length_km=1, diameter_m=0.03, k_mm=.1, sections=10, - alpha_w_per_m2k=1, name="Pipe 6") - pandapipes.create_sink(net, 9, mdot_kg_per_s=0.01, name="Sink 3") - pandapipes.create_source(net, junction=10, mdot_kg_per_s=0.04, name="Source 3") - pandapipes.create_compressor(net, from_junction=9, to_junction=3, pressure_ratio=1.1, - name="Compressor 0", index=None, in_service=True) - pandapipes.create_ext_grid(net, junction=3, t_k=300) - return net - - @pytest.mark.parametrize("use_numba", [True, False]) def test_inservice_gas(create_test_net, use_numba): """ @@ -169,7 +146,7 @@ def test_inservice_gas(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[~net.junction.in_service].values)) oos_sinks = np.isin(net.sink.junction.values, net.junction.index[~net.junction.in_service]) \ - | ~net.sink.in_service.values + | ~net.sink.in_service.values assert np.all(np.isnan(net.res_sink.loc[oos_sinks, :].values)) assert not np.any(np.isnan(net.res_pipe.v_mean_m_per_s.loc[net.pipe.in_service].values)) @@ -202,7 +179,7 @@ def test_inservice_water(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[~net.junction.in_service].values)) oos_sinks = np.isin(net.sink.junction.values, net.junction.index[~net.junction.in_service]) \ - | ~net.sink.in_service.values + | ~net.sink.in_service.values assert np.all(np.isnan(net.res_sink.loc[oos_sinks, :].values)) assert not any(np.isnan(net.res_pipe.v_mean_m_per_s.loc[net.pipe.in_service].values)) @@ -237,8 +214,8 @@ def test_connectivity_hydraulic(create_test_net, use_numba): assert np.all(np.isnan(net.res_pipe.loc[[1, 2, 3], :].values)) assert not np.any(np.isnan(net.res_junction.loc[[0, 1, 3, 4], :].values)) assert not np.any(np.isnan(net.res_pipe.loc[[0, 4], - ["v_mean_m_per_s", "p_from_bar", - "p_to_bar"]].values)) + ["v_mean_m_per_s", "p_from_bar", + "p_to_bar"]].values)) assert not np.any(np.isnan(net.res_sink.loc[[0, 2], "mdot_kg_per_s"].values)) assert np.all(np.isnan(net.res_sink.loc[[1, 3, 4], "mdot_kg_per_s"].values)) @@ -519,7 +496,7 @@ def test_mixed_indexing_oos2(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -537,7 +514,7 @@ def test_mixed_indexing_oos3(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -555,7 +532,7 @@ def test_mixed_indexing_oos4(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -573,7 +550,7 @@ def test_mixed_indexing_oos5(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -591,7 +568,7 @@ def test_mixed_indexing_oos6(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -600,22 +577,10 @@ def test_mixed_indexing_oos6(create_mixed_indexing_grid, use_numba): assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) -@pytest.mark.parametrize("use_numba", [True, False]) -def test_pipeflow_cancellation(create_net_wo_external_hydraulic_grid, use_numba): - net = create_net_wo_external_hydraulic_grid - pandapipes.pipeflow(net) - assert np.all(np.isnan(net.res_junction)) - assert np.all(np.isnan(net.res_pipe)) - assert np.all(np.isnan(net.res_ext_grid)) - assert np.all(np.isnan(net.res_sink)) - assert np.all(np.isnan(net.res_source)) - assert np.all(np.isnan(net.res_compressor)) - - if __name__ == "__main__": pytest.main([r'pandapipes/test/pipeflow_internals/test_inservice.py']) From e501c158c32294ab129635018667466f223ddca9 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 11:55:29 +0100 Subject: [PATCH 013/237] adding a __init__.py to the repo --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 000000000..e69de29bb From 17315e1d30b405189f0707269d059cd8fa047b36 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 11:58:12 +0100 Subject: [PATCH 014/237] might solve the problem --- .github/workflows/run_tests_develop.yml | 2 +- __init__.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 __init__.py diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index a172d407a..06a3de885 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,7 +101,7 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install . + pip install -e . - name: List all installed packages run: | pip list diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29bb..000000000 From e5a9571e9cd47cb19108b6a962a84b68975c7493 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 12:31:58 +0100 Subject: [PATCH 015/237] bug check --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4608f4c53..358d62406 100644 --- a/setup.py +++ b/setup.py @@ -49,8 +49,9 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(where="pandapipes"), - package_dir={"": "pandapipes"}, + #packages=find_namespace_packages(where="pandapipes"), + #package_dir={"": "pandapipes"}, + packages=find_namespace_packages(), include_package_data=True, classifiers=classifiers ) From 0fa38f139a69e2781a6eed6b974ff8a57d802014 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 14:11:35 +0100 Subject: [PATCH 016/237] upgrade setuptools due to bug --- .github/workflows/run_tests_develop.yml | 1 + setup.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 06a3de885..0fc69b8a6 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,6 +101,7 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower + pip install --upgrade setuptools pip install -e . - name: List all installed packages run: | diff --git a/setup.py b/setup.py index 358d62406..4608f4c53 100644 --- a/setup.py +++ b/setup.py @@ -49,9 +49,8 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - #packages=find_namespace_packages(where="pandapipes"), - #package_dir={"": "pandapipes"}, - packages=find_namespace_packages(), + packages=find_namespace_packages(where="pandapipes"), + package_dir={"": "pandapipes"}, include_package_data=True, classifiers=classifiers ) From 086f87731bd084a39a5c466f13a13ef74a8e92c7 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 14:15:25 +0100 Subject: [PATCH 017/237] check for bugfix --- .github/workflows/run_tests_develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 0fc69b8a6..7924f63b2 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -108,7 +108,7 @@ jobs: pip list - name: Test with pytest run: | - pytest --nbmake -n=auto "./tutorials" + python -m pytest --nbmake -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest From ac372c48b992e268db6f703456620a0bb89f6f4d Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 14:40:31 +0100 Subject: [PATCH 018/237] removing upgrade setuptools --- .github/workflows/run_tests_develop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 7924f63b2..a3bb4f6d0 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,7 +101,6 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install --upgrade setuptools pip install -e . - name: List all installed packages run: | From cb124274c0a443b54c4b98b3cab0c7b78b62e901 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:20:42 +0100 Subject: [PATCH 019/237] pip install with pip install . --- .github/workflows/run_tests_develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index a3bb4f6d0..985bd23ee 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,7 +101,7 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install -e . + pip install . - name: List all installed packages run: | pip list From 92b04ce6dbed8a8010065e1596d07fbc1849a416 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:23:23 +0100 Subject: [PATCH 020/237] trying with python -m pip install . --- .github/workflows/run_tests_develop.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 985bd23ee..fb0e4a4d0 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,7 +101,8 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install . + python -m pip install . + - name: List all installed packages run: | pip list From f56fa14ca580dbdbe0225a74b525c8b6fa63c85c Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:25:54 +0100 Subject: [PATCH 021/237] trying to upgrade jupyter --- .github/workflows/run_tests_develop.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index fb0e4a4d0..d6a78ee09 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -96,12 +96,13 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split igraph + pip install --upgrade pip + pip install pytest nbmake pytest-xdist pytest-split igraph if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - python -m pip install . + pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower + pip install --upgrade jupyter + pip install . - name: List all installed packages run: | From 5b17399ab08c0e0de52629d046f7b90c1fb50db2 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:37:56 +0100 Subject: [PATCH 022/237] trying to solve problem with python -m --- .github/workflows/run_tests_develop.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index d6a78ee09..fb0e4a4d0 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -96,13 +96,12 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install --upgrade pip - pip install pytest nbmake pytest-xdist pytest-split igraph + python -m pip install --upgrade pip + python -m pip install pytest nbmake pytest-xdist pytest-split igraph if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install --upgrade jupyter - pip install . + python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower + python -m pip install . - name: List all installed packages run: | From d75caad2805ccda836656a68f52a912ee6ffe816 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:43:12 +0100 Subject: [PATCH 023/237] install jupyter --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index fb0e4a4d0..ab53ed7ab 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,6 +101,7 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower + python -m pip install jupyter python -m pip install . - name: List all installed packages From 521d38a72d0b76bbf2b38a44b6009fde373ba2e0 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:50:51 +0100 Subject: [PATCH 024/237] install pytest-pythonpath --- .github/workflows/run_tests_develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index ab53ed7ab..fb5d204f5 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -97,7 +97,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split igraph + python -m pip install pytest nbmake pytest-xdist pytest-split igraph pytest-pythonpath if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower From 6df52d4b30723981c0e1687781bb5126dfd90660 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 20:53:42 +0100 Subject: [PATCH 025/237] upgrade setuptools --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index fb5d204f5..b8a18ac9a 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -102,6 +102,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install jupyter + python -m pip install --upgrade setuptools python -m pip install . - name: List all installed packages From cdc5f8df4b5d57a9cd5d07fcda249d700ad08acd Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:06:51 +0100 Subject: [PATCH 026/237] upgrade pytest --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index b8a18ac9a..f71a4283d 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -103,6 +103,7 @@ jobs: python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install jupyter python -m pip install --upgrade setuptools + python -m pip install --upgrade pytest python -m pip install . - name: List all installed packages From ba5828ebce8b14ed7eb84281f78c9a23c5fad491 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:22:13 +0100 Subject: [PATCH 027/237] further packages installed --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index f71a4283d..7ae405bfe 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -104,6 +104,7 @@ jobs: python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest + python -m pip install atomicwrites colorama pywinpty pywin32 python -m pip install . - name: List all installed packages From eba1c19404825653c76b80d7158ac1c368301b12 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:26:02 +0100 Subject: [PATCH 028/237] further packages installed --- .github/workflows/run_tests_develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 7ae405bfe..2cc2094e2 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -104,7 +104,7 @@ jobs: python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest - python -m pip install atomicwrites colorama pywinpty pywin32 + python -m pip install atomicwrites colorama python -m pip install . - name: List all installed packages From 380d39a40edd49bcdf6d8f1c394c2f7881796078 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:41:49 +0100 Subject: [PATCH 029/237] uninstall certain packages --- .github/workflows/run_tests_develop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 2cc2094e2..8c19b9f1e 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -101,12 +101,12 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower + python -m pip install . python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest python -m pip install atomicwrites colorama - python -m pip install . - + python -m pip uninstall pexpect ptyprocess - name: List all installed packages run: | pip list From 8becbb9da781f9fea24ae8b61a8912cc0151ed09 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:46:47 +0100 Subject: [PATCH 030/237] downgrade packages --- .github/workflows/run_tests_develop.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 8c19b9f1e..476149a52 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -105,8 +105,9 @@ jobs: python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest - python -m pip install atomicwrites colorama - python -m pip uninstall pexpect ptyprocess + python -m pip install prompt-toolkit==3.0.41 + python -m pip install Babel==2.13.1 + - name: List all installed packages run: | pip list From 3c8db9bd93a743b6b3f879d52f42e04958ef2612 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:50:47 +0100 Subject: [PATCH 031/237] install further packages --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 476149a52..2036fa936 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -105,6 +105,7 @@ jobs: python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest + python -m pip install atomicwrites colorama python -m pip install prompt-toolkit==3.0.41 python -m pip install Babel==2.13.1 From 26b65a3e8c73dddb2226e05034afb35eb386a53a Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 21:58:39 +0100 Subject: [PATCH 032/237] install ipython --- .github/workflows/run_tests_develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 2036fa936..2294cbce6 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -105,7 +105,7 @@ jobs: python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest - python -m pip install atomicwrites colorama + python -m pip install atomicwrites colorama ipython python -m pip install prompt-toolkit==3.0.41 python -m pip install Babel==2.13.1 From f7e9b7cce291ceb024ba7061b5fc85baa2b1e7e1 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 12 Dec 2023 22:07:11 +0100 Subject: [PATCH 033/237] adding a pytest.ini --- pandapipes/pytest.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pandapipes/pytest.ini diff --git a/pandapipes/pytest.ini b/pandapipes/pytest.ini new file mode 100644 index 000000000..1134c8c6f --- /dev/null +++ b/pandapipes/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . .. pandapipes \ No newline at end of file From c39e1bdd853b714747414e345c68c4590a5edb17 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 10:22:30 +0100 Subject: [PATCH 034/237] add pandapipes. in front of namespace folder paths --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4608f4c53..9557f6d80 100644 --- a/setup.py +++ b/setup.py @@ -49,8 +49,7 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(where="pandapipes"), - package_dir={"": "pandapipes"}, + packages= ['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")], include_package_data=True, classifiers=classifiers ) From 278e850659a34d81e706a6f73d2c46d29aeea976 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 10:35:15 +0100 Subject: [PATCH 035/237] calling pythonpath and sys path --- .github/workflows/run_tests_develop.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 2294cbce6..1bbb6326d 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -112,6 +112,12 @@ jobs: - name: List all installed packages run: | pip list + - name: Get PYTHONPATH + run: | + echo $PYTHONPATH + - name: Get sys path + run: | + python -c "import sys; print(sys.path)" - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" From c9824573fe054e4021351a972c4f24e4786b4afb Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 10:56:27 +0100 Subject: [PATCH 036/237] call pandapipes packages --- .github/workflows/run_tests_develop.yml | 3 +++ pandapipes/pytest.ini | 2 -- setup.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 pandapipes/pytest.ini diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 1bbb6326d..bbc09f9e3 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -118,6 +118,9 @@ jobs: - name: Get sys path run: | python -c "import sys; print(sys.path)" + - name: List pandapipes packages + run: | + python -c "import sys; import os; from setuptools import find_packages; print(find_packages(where=os.path.join([p for p in sys.path if p.endswith('site-packages')][0], 'pandapipes')))" - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" diff --git a/pandapipes/pytest.ini b/pandapipes/pytest.ini deleted file mode 100644 index 1134c8c6f..000000000 --- a/pandapipes/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -pythonpath = . .. pandapipes \ No newline at end of file diff --git a/setup.py b/setup.py index 9557f6d80..c08f3c9e3 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,8 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages= ['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")], + packages= find_namespace_packages(where="pandapipes"), + package_dir={"": "pandapipes"}, include_package_data=True, classifiers=classifiers ) From 047332d5c337d16daac77617c7d6e7a5ce414652 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:13:43 +0100 Subject: [PATCH 037/237] uninstall pytest-pythonpath --- .github/workflows/run_tests_develop.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index bbc09f9e3..e3bcb5d63 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -97,15 +97,16 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split igraph pytest-pythonpath + python -m pip install pytest nbmake pytest-xdist pytest-split igraph if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . + python -m pip uninstall pytest-pythonpath python -m pip install jupyter python -m pip install --upgrade setuptools python -m pip install --upgrade pytest - python -m pip install atomicwrites colorama ipython + python -m pip install atomicwrites colorama ipython pytest-pythonpath python -m pip install prompt-toolkit==3.0.41 python -m pip install Babel==2.13.1 From 3dc066692701a89673b4c86f9cc4afdf2bc58dd2 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:18:00 +0100 Subject: [PATCH 038/237] add a pytest.ini --- pandapipes/pytest.ini | 3 +++ tutorials/pytest.ini | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 pandapipes/pytest.ini create mode 100644 tutorials/pytest.ini diff --git a/pandapipes/pytest.ini b/pandapipes/pytest.ini new file mode 100644 index 000000000..a01d26adf --- /dev/null +++ b/pandapipes/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_paths = . .. +site_dirs = . .. \ No newline at end of file diff --git a/tutorials/pytest.ini b/tutorials/pytest.ini new file mode 100644 index 000000000..a01d26adf --- /dev/null +++ b/tutorials/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_paths = . .. +site_dirs = . .. \ No newline at end of file From 89909515ea7073ef337dc216fc72b0e85791d96c Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:22:13 +0100 Subject: [PATCH 039/237] add pytest.ini and adapt setup.py --- pandapipes/pytest.ini => pytest.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pandapipes/pytest.ini => pytest.ini (100%) diff --git a/pandapipes/pytest.ini b/pytest.ini similarity index 100% rename from pandapipes/pytest.ini rename to pytest.ini From bfe67fe8252cee6c9f78c7919295dc5e7076d359 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:22:19 +0100 Subject: [PATCH 040/237] add pytest.ini and adapt setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c08f3c9e3..8937708dc 100644 --- a/setup.py +++ b/setup.py @@ -49,8 +49,7 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages= find_namespace_packages(where="pandapipes"), - package_dir={"": "pandapipes"}, + packages= ['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")] + ['pandapipes'], include_package_data=True, classifiers=classifiers ) From 9dfe30b50823979e47cc75fedbe1127a0fafd7d7 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:25:54 +0100 Subject: [PATCH 041/237] first try only with pytest.ini --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8937708dc..c08f3c9e3 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,8 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages= ['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")] + ['pandapipes'], + packages= find_namespace_packages(where="pandapipes"), + package_dir={"": "pandapipes"}, include_package_data=True, classifiers=classifiers ) From 968495a04ab8ba2e46c534ac020fcab4a6efe125 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 13:41:51 +0100 Subject: [PATCH 042/237] solution to problem --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c08f3c9e3..9e8d009f0 100644 --- a/setup.py +++ b/setup.py @@ -49,8 +49,7 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages= find_namespace_packages(where="pandapipes"), - package_dir={"": "pandapipes"}, + packages=['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")]+ ['pandapipes'], include_package_data=True, classifiers=classifiers ) From 0cbeaa90ecb294556369bd139d61e68b07d4afc0 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 14:06:01 +0100 Subject: [PATCH 043/237] move everything in src folder --- .github/workflows/run_tests_develop.yml | 17 ----------------- setup.py | 3 ++- {pandapipes => src/pandapipes}/__init__.py | 0 .../pandapipes}/component_models/__init__.py | 0 .../abstract_models/__init__.py | 0 .../abstract_models/base_component.py | 0 .../abstract_models/branch_models.py | 0 .../branch_w_internals_models.py | 0 .../branch_wo_internals_models.py | 0 .../branch_wzerolength_models.py | 0 .../abstract_models/circulation_pump.py | 0 .../abstract_models/const_flow_models.py | 0 .../abstract_models/node_element_models.py | 0 .../abstract_models/node_models.py | 0 .../circulation_pump_mass_component.py | 0 .../circulation_pump_pressure_component.py | 0 .../component_models/component_toolbox.py | 0 .../component_models/compressor_component.py | 0 .../component_models/ext_grid_component.py | 0 .../component_models/flow_control_component.py | 0 .../heat_exchanger_component.py | 0 .../component_models/junction_component.py | 0 .../component_models/mass_storage_component.py | 0 .../component_models/pipe_component.py | 0 .../pressure_control_component.py | 0 .../component_models/pump_component.py | 0 .../component_models/sink_component.py | 0 .../component_models/source_component.py | 0 .../component_models/valve_component.py | 0 {pandapipes => src/pandapipes}/constants.py | 0 .../pandapipes}/control/__init__.py | 0 .../pandapipes}/control/run_control.py | 0 .../pandapipes}/converter/__init__.py | 0 .../pandapipes}/converter/stanet/__init__.py | 0 .../converter/stanet/data_cleaning.py | 0 .../converter/stanet/preparing_steps.py | 0 .../converter/stanet/stanet2pandapipes.py | 0 .../converter/stanet/table_creation.py | 0 .../stanet/valve_pipe_component/__init__.py | 0 .../valve_pipe_component/create_valve_pipe.py | 0 .../valve_pipe_component.py | 0 .../valve_pipe_component/valve_pipe_plotting.py | 0 {pandapipes => src/pandapipes}/create.py | 0 {pandapipes => src/pandapipes}/idx_branch.py | 0 {pandapipes => src/pandapipes}/idx_node.py | 0 {pandapipes => src/pandapipes}/io/__init__.py | 0 .../pandapipes}/io/convert_format.py | 0 {pandapipes => src/pandapipes}/io/file_io.py | 0 {pandapipes => src/pandapipes}/io/io_utils.py | 0 .../pandapipes}/multinet/__init__.py | 0 .../pandapipes}/multinet/control/__init__.py | 0 .../multinet/control/controller/__init__.py | 0 .../control/controller/multinet_control.py | 0 .../multinet/control/run_control_multinet.py | 0 .../pandapipes}/multinet/create_multinet.py | 0 .../pandapipes}/multinet/multinet.py | 0 .../pandapipes}/multinet/timeseries/__init__.py | 0 .../timeseries/run_time_series_multinet.py | 0 .../pandapipes}/networks/__init__.py | 0 .../gas_net_schutterwald_1bar.json | 0 .../heat_transfer_cases/delta.json | 0 .../heat_transfer_cases/delta_2sinks.json | 0 .../heat_transfer_cases/heights.json | 0 .../heat_transfer_cases/one_pipe.json | 0 .../heat_transfer_cases/one_source.json | 0 .../heat_transfer_cases/section_variation.json | 0 .../heat_transfer_cases/t_cross.json | 0 .../heat_transfer_cases/two_pipes.json | 0 .../combined_networks/mixed_net.json | 0 .../combined_networks/versatility.json | 0 .../meshed_networks/delta.json | 0 .../meshed_networks/heights.json | 0 .../meshed_networks/pumps.json | 0 .../meshed_networks/two_valves.json | 0 .../water_cases_colebrook/one_pipe/pipe_1.json | 0 .../water_cases_colebrook/one_pipe/pipe_2.json | 0 .../water_cases_colebrook/one_pipe/pipe_3.json | 0 .../strand_net/cross_3ext.json | 0 .../strand_net/strand_net.json | 0 .../strand_net/two_pipes.json | 0 .../strand_net/two_pumps.json | 0 .../water_cases_colebrook/t_cross/t_cross.json | 0 .../water_cases_colebrook/t_cross/valves.json | 0 .../two_pressure_junctions/two_pipes.json | 0 .../combined_networks/mixed_net.json | 0 .../combined_networks/versatility.json | 0 .../meshed_networks/delta.json | 0 .../meshed_networks/heights.json | 0 .../meshed_networks/one_valve_stanet.json | 0 .../meshed_networks/pumps.json | 0 .../meshed_networks/two_valves.json | 0 .../one_pipe/pipe_1.json | 0 .../one_pipe/pipe_2.json | 0 .../one_pipe/pipe_3.json | 0 .../strand_net/cross_3ext.json | 0 .../strand_net/strand_net.json | 0 .../strand_net_stanet_variation1.json | 0 .../strand_net_stanet_variation2.json | 0 .../strand_net/two_pipes.json | 0 .../strand_net/two_pumps.json | 0 .../t_cross/t_cross.json | 0 .../water_cases_swamee-jain/t_cross/valves.json | 0 .../two_pressure_junctions/one_pipe_stanet.json | 0 .../two_pressure_junctions/two_pipes.json | 0 .../1-LV-rural1--0-no_sw.json | 0 .../1-LV-rural1--0-sw.json | 0 .../1-LV-rural2--0-no_sw.json | 0 .../1-LV-rural2--0-sw.json | 0 .../1-LV-rural3--0-no_sw.json | 0 .../1-LV-rural3--0-sw.json | 0 .../1-LV-semiurb4--0-no_sw.json | 0 .../1-LV-semiurb4--0-sw.json | 0 .../1-LV-semiurb5--0-no_sw.json | 0 .../1-LV-semiurb5--0-sw.json | 0 .../1-LV-urban6--0-no_sw.json | 0 .../1-LV-urban6--0-sw.json | 0 .../gas_cases/combined_networks/parallel_N.json | 0 .../combined_networks/parallel_PC.json | 0 .../combined_networks/versatility_PC.json | 0 .../gas_cases/meshed_networks/delta_PC.json | 0 .../gas_cases/meshed_networks/pumps_N.json | 0 .../gas_cases/meshed_networks/square_N.json | 0 .../gas_cases/meshed_networks/square_PC.json | 0 .../gas_cases/meshed_networks/two_valves_N.json | 0 .../meshed_networks/two_valves_PC.json | 0 .../gas_cases/one_pipe/pipe_1_N.json | 0 .../gas_cases/one_pipe/pipe_1_PC.json | 0 .../gas_cases/one_pipe/pipe_2_N.json | 0 .../gas_cases/one_pipe/pipe_2_PC.json | 0 .../gas_cases/strand_net/pump_N.json | 0 .../gas_cases/strand_net/two_pipes_N.json | 0 .../gas_cases/strand_net/two_pipes_PC.json | 0 .../gas_cases/t_cross/t_cross1_N.json | 0 .../gas_cases/t_cross/t_cross1_PC.json | 0 .../gas_cases/t_cross/t_cross2_N.json | 0 .../gas_cases/t_cross/t_cross2_PC.json | 0 .../two_pressure_junctions/H_net_N.json | 0 .../two_pressure_junctions/H_net_PC.json | 0 .../combined_networks/district_N.json | 0 .../combined_networks/district_PC.json | 0 .../combined_networks/versatility_N.json | 0 .../combined_networks/versatility_PC.json | 0 .../water_cases/meshed_networks/delta_N.json | 0 .../water_cases/meshed_networks/pumps_N.json | 0 .../meshed_networks/two_valves_N.json | 0 .../meshed_networks/two_valves_PC.json | 0 .../water_cases/one_pipe/pipe_1_N.json | 0 .../water_cases/one_pipe/pipe_1_PC.json | 0 .../water_cases/one_pipe/pipe_2_N.json | 0 .../water_cases/one_pipe/pipe_2_PC.json | 0 .../water_cases/one_pipe/pipe_3_N.json | 0 .../water_cases/one_pipe/pipe_3_PC.json | 0 .../water_cases/strand_net/cross_PC.json | 0 .../water_cases/strand_net/pump_N.json | 0 .../water_cases/strand_net/strand_net_N.json | 0 .../water_cases/strand_net/strand_net_PC.json | 0 .../water_cases/strand_net/two_pipes_N.json | 0 .../water_cases/strand_net/two_pipes_PC.json | 0 .../water_cases/t_cross/t_cross_N.json | 0 .../water_cases/t_cross/t_cross_PC.json | 0 .../two_pressure_junctions/two_pipes_N.json | 0 .../two_pressure_junctions/two_pipes_PC.json | 0 .../pandapipes}/networks/nw_aux.py | 0 .../pandapipes}/networks/simple_gas_networks.py | 0 .../networks/simple_heat_transfer_networks.py | 0 .../networks/simple_water_networks.py | 0 .../pandapipes}/pandapipes_net.py | 0 {pandapipes => src/pandapipes}/pf/__init__.py | 0 .../pandapipes}/pf/build_system_matrix.py | 0 .../pandapipes}/pf/derivative_calculation.py | 0 .../pandapipes}/pf/derivative_toolbox.py | 0 .../pandapipes}/pf/derivative_toolbox_numba.py | 0 .../pandapipes}/pf/internals_toolbox.py | 0 .../pandapipes}/pf/pipeflow_setup.py | 0 .../pandapipes}/pf/result_extraction.py | 0 {pandapipes => src/pandapipes}/pipeflow.py | 0 .../pandapipes}/plotting/__init__.py | 0 .../pandapipes}/plotting/collections.py | 0 .../pandapipes}/plotting/generic_geodata.py | 0 {pandapipes => src/pandapipes}/plotting/geo.py | 0 .../pandapipes}/plotting/patch_makers.py | 0 .../pandapipes}/plotting/pipeflow_results.py | 0 .../pandapipes}/plotting/plotting_toolbox.py | 0 .../pandapipes}/plotting/simple_plot.py | 0 .../pandapipes}/properties/__init__.py | 0 .../properties/air/compressibility.txt | 0 .../pandapipes}/properties/air/density.txt | 0 .../properties/air/der_compressibility.txt | 0 .../properties/air/heat_capacity.txt | 0 .../pandapipes}/properties/air/molar_mass.txt | 0 .../pandapipes}/properties/air/viscosity.txt | 0 .../biomethane_pure/compressibility.txt | 0 .../properties/biomethane_pure/density.txt | 0 .../biomethane_pure/der_compressibility.txt | 0 .../biomethane_pure/gas_composition.txt | 0 .../biomethane_pure/heat_capacity.txt | 0 .../biomethane_pure/higher_heating_value.txt | 0 .../biomethane_pure/lower_heating_value.txt | 0 .../properties/biomethane_pure/molar_mass.txt | 0 .../properties/biomethane_pure/viscosity.txt | 0 .../biomethane_treated/compressibility.txt | 0 .../properties/biomethane_treated/density.txt | 0 .../biomethane_treated/der_compressibility.txt | 0 .../biomethane_treated/gas_composition.txt | 0 .../biomethane_treated/heat_capacity.txt | 0 .../biomethane_treated/higher_heating_value.txt | 0 .../biomethane_treated/lower_heating_value.txt | 0 .../biomethane_treated/molar_mass.txt | 0 .../properties/biomethane_treated/viscosity.txt | 0 .../properties/carbondioxide/density.txt | 0 .../properties/carbondioxide/heat_capacity.txt | 0 .../properties/carbondioxide/molar_mass.txt | 0 .../properties/carbondioxide/viscosity.txt | 0 .../pandapipes}/properties/ethane/density.txt | 0 .../properties/ethane/heat_capacity.txt | 0 .../properties/ethane/molar_mass.txt | 0 .../pandapipes}/properties/ethane/viscosity.txt | 0 .../pandapipes}/properties/fluids.py | 0 .../properties/hgas/compressibility.txt | 0 .../pandapipes}/properties/hgas/density.txt | 0 .../properties/hgas/der_compressibility.txt | 0 .../properties/hgas/heat_capacity.txt | 0 .../properties/hgas/higher_heating_value.txt | 0 .../properties/hgas/lower_heating_value.txt | 0 .../pandapipes}/properties/hgas/molar_mass.txt | 0 .../pandapipes}/properties/hgas/viscosity.txt | 0 .../properties/hydrogen/compressibility.txt | 0 .../pandapipes}/properties/hydrogen/density.txt | 0 .../properties/hydrogen/der_compressibility.txt | 0 .../properties/hydrogen/heat_capacity.txt | 0 .../hydrogen/higher_heating_value.txt | 0 .../properties/hydrogen/lower_heating_value.txt | 0 .../properties/hydrogen/molar_mass.txt | 0 .../properties/hydrogen/viscosity.txt | 0 .../properties/lgas/compressibility.txt | 0 .../pandapipes}/properties/lgas/density.txt | 0 .../properties/lgas/der_compressibility.txt | 0 .../properties/lgas/heat_capacity.txt | 0 .../properties/lgas/higher_heating_value.txt | 0 .../properties/lgas/lower_heating_value.txt | 0 .../pandapipes}/properties/lgas/molar_mass.txt | 0 .../pandapipes}/properties/lgas/viscosity.txt | 0 .../properties/methane/compressibility.txt | 0 .../pandapipes}/properties/methane/density.txt | 0 .../properties/methane/der_compressibility.txt | 0 .../properties/methane/heat_capacity.txt | 0 .../properties/methane/higher_heating_value.txt | 0 .../properties/methane/lower_heating_value.txt | 0 .../properties/methane/molar_mass.txt | 0 .../properties/methane/viscosity.txt | 0 .../pandapipes}/properties/nitrogen/density.txt | 0 .../properties/nitrogen/heat_capacity.txt | 0 .../properties/nitrogen/molar_mass.txt | 0 .../properties/nitrogen/viscosity.txt | 0 .../pandapipes}/properties/oxygen/density.txt | 0 .../properties/oxygen/heat_capacity.txt | 0 .../properties/oxygen/molar_mass.txt | 0 .../pandapipes}/properties/oxygen/viscosity.txt | 0 .../properties/properties_toolbox.py | 0 .../properties/water/compressibility.txt | 0 .../pandapipes}/properties/water/density.txt | 0 .../properties/water/der_compressibility.txt | 0 .../properties/water/heat_capacity.txt | 0 .../pandapipes}/properties/water/molar_mass.txt | 0 .../pandapipes}/properties/water/viscosity.txt | 0 .../pandapipes}/std_types/__init__.py | 0 .../pandapipes}/std_types/library/Pipe.csv | 0 .../pandapipes}/std_types/library/Pump/P1.csv | 0 .../pandapipes}/std_types/library/Pump/P2.csv | 0 .../pandapipes}/std_types/library/Pump/P3.csv | 0 .../pandapipes}/std_types/std_type_class.py | 0 .../pandapipes}/std_types/std_types.py | 0 {pandapipes => src/pandapipes}/test/__init__.py | 0 .../pandapipes}/test/api/__init__.py | 0 .../test/api/old_versions/example_0.1.0.json | 0 .../test/api/old_versions/example_0.1.1.json | 0 .../test/api/old_versions/example_0.1.2.json | 0 .../test/api/old_versions/example_0.2.0.json | 0 .../test/api/old_versions/example_0.4.0.json | 0 .../test/api/old_versions/example_0.5.0.json | 0 .../test/api/old_versions/example_0.6.0.json | 0 .../test/api/old_versions/example_0.7.0.json | 0 .../api/old_versions/example_0.8.0_gas.json | 0 .../api/old_versions/example_0.8.0_water.json | 0 .../api/old_versions/example_0.8.1_gas.json | 0 .../api/old_versions/example_0.8.1_water.json | 0 .../api/old_versions/example_0.8.2_gas.json | 0 .../api/old_versions/example_0.8.2_water.json | 0 .../api/old_versions/example_0.8.3_gas.json | 0 .../api/old_versions/example_0.8.3_water.json | 0 .../api/old_versions/example_0.8.4_gas.json | 0 .../api/old_versions/example_0.8.4_water.json | 0 .../api/old_versions/example_0.8.5_gas.json | 0 .../api/old_versions/example_0.8.5_water.json | 0 .../release_control_test_network.py | 0 .../release_control_test_sink_profiles.csv | 0 .../release_control_test_source_profiles.csv | 0 .../pandapipes}/test/api/test_aux_function.py | 0 .../test/api/test_components/__init__.py | 0 .../api/test_components/test_circ_pump_mass.py | 0 .../test_components/test_circ_pump_pressure.py | 0 .../test/api/test_components/test_compressor.py | 0 .../test/api/test_components/test_ext_grid.py | 0 .../api/test_components/test_flow_control.py | 0 .../api/test_components/test_heat_exchanger.py | 0 .../api/test_components/test_mass_storage.py | 0 .../api/test_components/test_pipe_results.py | 0 .../test_components/test_pressure_control.py | 0 .../test/api/test_components/test_pump.py | 0 .../test/api/test_components/test_valve.py | 0 .../pandapipes}/test/api/test_convert_format.py | 0 .../pandapipes}/test/api/test_create.py | 0 .../pandapipes}/test/api/test_network_tables.py | 0 .../test/api/test_special_networks.py | 0 .../pandapipes}/test/api/test_std_types.py | 0 .../pandapipes}/test/api/test_time_series.py | 0 .../pandapipes}/test/converter/__init__.py | 0 .../converter_test_files/Exampelonia_mini.csv | 0 .../Exampelonia_mini_with_2valvepipe.csv | 0 ...mpelonia_mini_with_valve_2sliders_closed.csv | 0 ...xampelonia_mini_with_valve_2sliders_open.csv | 0 .../test/converter/test_stanet_converter.py | 0 .../pandapipes}/test/io/__init__.py | 0 .../pandapipes}/test/io/test_file_io.py | 0 .../pandapipes}/test/multinet/__init__.py | 0 .../test/multinet/test_control_multinet.py | 0 .../test/multinet/test_time_series_multinet.py | 0 .../pandapipes}/test/networks/__init__.py | 0 .../pandapipes}/test/networks/test_networks.py | 0 .../test/openmodelica_comparison/__init__.py | 0 .../pipeflow_openmodelica_comparison.py | 0 .../test_heat_transfer_openmodelica.py | 0 .../test_water_openmodelica.py | 0 .../test/pipeflow_internals/__init__.py | 0 .../data/Temperature_2zu_2ab_an.csv | 0 .../data/Temperature_masche_1load_an.csv | 0 .../Temperature_masche_1load_direction_an.csv | 0 .../data/Temperature_one_pipe_an.csv | 0 .../data/Temperature_tee_2ab_1zu_an.csv | 0 .../data/Temperature_tee_2zu_1ab_an.csv | 0 .../test/pipeflow_internals/data/ext_grid_p.csv | 0 .../pipeflow_internals/data/gas_sections_an.csv | 0 .../data/heat_exchanger_test.csv | 0 .../test/pipeflow_internals/data/hydraulics.csv | 0 .../data/pressure_control_test_analytical.csv | 0 .../data/test_circ_pump_mass.csv | 0 .../data/test_circ_pump_pressure.csv | 0 .../data/test_pressure_control.csv | 0 .../test/pipeflow_internals/data/test_pump.csv | 0 .../res_ext_grid/mdot_kg_per_s.csv | 0 .../res_junction/p_bar.csv | 0 .../res_pipe/lambda.csv | 0 .../res_pipe/reynolds.csv | 0 .../res_pipe/v_mean_m_per_s.csv | 0 .../res_sink/mdot_kg_per_s.csv | 0 .../res_source/mdot_kg_per_s.csv | 0 .../data/test_time_series_sink_profiles.csv | 0 .../data/test_time_series_source_profiles.csv | 0 .../test/pipeflow_internals/data/test_valve.csv | 0 .../test/pipeflow_internals/test_inservice.py | 0 .../pipeflow_internals/test_non_convergence.py | 0 .../test/pipeflow_internals/test_options.py | 0 .../test_pipeflow_analytic_comparison.py | 0 .../pipeflow_internals/test_pipeflow_modes.py | 0 .../test/pipeflow_internals/test_time_series.py | 0 .../pipeflow_internals/test_update_matrix.py | 0 .../pandapipes}/test/plotting/__init__.py | 0 .../test/plotting/test_collections.py | 0 .../test/plotting/test_generic_coordinates.py | 0 .../test/plotting/test_pipeflow_results.py | 0 .../test/plotting/test_simple_collections.py | 0 .../pandapipes}/test/properties/__init__.py | 0 .../test/properties/test_fluid_specials.py | 0 .../test/properties/test_properties_toolbox.py | 0 {pandapipes => src/pandapipes}/test/pytest.ini | 0 .../pandapipes}/test/run_tests.py | 0 .../test/stanet_comparison/__init__.py | 0 .../pipeflow_stanet_comparison.py | 0 .../test/stanet_comparison/test_gas_stanet.py | 0 .../test/stanet_comparison/test_water_stanet.py | 0 .../pandapipes}/test/test_imports.py | 0 .../pandapipes}/test/test_toolbox.py | 0 .../pandapipes}/test/topology/__init__.py | 0 .../test/topology/test_graph_searches.py | 0 .../pandapipes}/test/topology/test_nxgraph.py | 0 .../pandapipes}/timeseries/__init__.py | 0 .../pandapipes}/timeseries/run_time_series.py | 0 {pandapipes => src/pandapipes}/toolbox.py | 0 .../pandapipes}/topology/__init__.py | 0 .../pandapipes}/topology/create_graph.py | 0 .../pandapipes}/topology/graph_searches.py | 0 391 files changed, 2 insertions(+), 18 deletions(-) rename {pandapipes => src/pandapipes}/__init__.py (100%) rename {pandapipes => src/pandapipes}/component_models/__init__.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/__init__.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/base_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/branch_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/branch_w_internals_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/branch_wo_internals_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/branch_wzerolength_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/circulation_pump.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/const_flow_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/node_element_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/abstract_models/node_models.py (100%) rename {pandapipes => src/pandapipes}/component_models/circulation_pump_mass_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/circulation_pump_pressure_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/component_toolbox.py (100%) rename {pandapipes => src/pandapipes}/component_models/compressor_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/ext_grid_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/flow_control_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/heat_exchanger_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/junction_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/mass_storage_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/pipe_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/pressure_control_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/pump_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/sink_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/source_component.py (100%) rename {pandapipes => src/pandapipes}/component_models/valve_component.py (100%) rename {pandapipes => src/pandapipes}/constants.py (100%) rename {pandapipes => src/pandapipes}/control/__init__.py (100%) rename {pandapipes => src/pandapipes}/control/run_control.py (100%) rename {pandapipes => src/pandapipes}/converter/__init__.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/__init__.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/data_cleaning.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/preparing_steps.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/stanet2pandapipes.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/table_creation.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/valve_pipe_component/__init__.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/valve_pipe_component/create_valve_pipe.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/valve_pipe_component/valve_pipe_component.py (100%) rename {pandapipes => src/pandapipes}/converter/stanet/valve_pipe_component/valve_pipe_plotting.py (100%) rename {pandapipes => src/pandapipes}/create.py (100%) rename {pandapipes => src/pandapipes}/idx_branch.py (100%) rename {pandapipes => src/pandapipes}/idx_node.py (100%) rename {pandapipes => src/pandapipes}/io/__init__.py (100%) rename {pandapipes => src/pandapipes}/io/convert_format.py (100%) rename {pandapipes => src/pandapipes}/io/file_io.py (100%) rename {pandapipes => src/pandapipes}/io/io_utils.py (100%) rename {pandapipes => src/pandapipes}/multinet/__init__.py (100%) rename {pandapipes => src/pandapipes}/multinet/control/__init__.py (100%) rename {pandapipes => src/pandapipes}/multinet/control/controller/__init__.py (100%) rename {pandapipes => src/pandapipes}/multinet/control/controller/multinet_control.py (100%) rename {pandapipes => src/pandapipes}/multinet/control/run_control_multinet.py (100%) rename {pandapipes => src/pandapipes}/multinet/create_multinet.py (100%) rename {pandapipes => src/pandapipes}/multinet/multinet.py (100%) rename {pandapipes => src/pandapipes}/multinet/timeseries/__init__.py (100%) rename {pandapipes => src/pandapipes}/multinet/timeseries/run_time_series_multinet.py (100%) rename {pandapipes => src/pandapipes}/networks/__init__.py (100%) rename {pandapipes => src/pandapipes}/networks/network_files/gas_net_schutterwald_1bar.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta_2sinks.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/heights.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_pipe.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_source.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/section_variation.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/t_cross.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/heat_transfer_cases/two_pipes.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/mixed_net.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/versatility.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/delta.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/heights.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/pumps.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/two_valves.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_1.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_2.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_3.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/cross_3ext.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/strand_net.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pipes.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pumps.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/t_cross.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/valves.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_colebrook/two_pressure_junctions/two_pipes.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/mixed_net.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/versatility.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/delta.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/heights.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/one_valve_stanet.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/pumps.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/two_valves.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_1.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_2.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_3.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/cross_3ext.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation1.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation2.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pipes.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pumps.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/t_cross.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/valves.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/one_pipe_stanet.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/two_pipes.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural1--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural1--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural2--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural2--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural3--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-rural3--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-urban6--0-no_sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/simbench_test_networks/1-LV-urban6--0-sw.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/combined_networks/versatility_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/delta_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/pumps_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/strand_net/pump_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/meshed_networks/delta_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/meshed_networks/pumps_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/cross_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/pump_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_N.json (100%) rename {pandapipes => src/pandapipes}/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_PC.json (100%) rename {pandapipes => src/pandapipes}/networks/nw_aux.py (100%) rename {pandapipes => src/pandapipes}/networks/simple_gas_networks.py (100%) rename {pandapipes => src/pandapipes}/networks/simple_heat_transfer_networks.py (100%) rename {pandapipes => src/pandapipes}/networks/simple_water_networks.py (100%) rename {pandapipes => src/pandapipes}/pandapipes_net.py (100%) rename {pandapipes => src/pandapipes}/pf/__init__.py (100%) rename {pandapipes => src/pandapipes}/pf/build_system_matrix.py (100%) rename {pandapipes => src/pandapipes}/pf/derivative_calculation.py (100%) rename {pandapipes => src/pandapipes}/pf/derivative_toolbox.py (100%) rename {pandapipes => src/pandapipes}/pf/derivative_toolbox_numba.py (100%) rename {pandapipes => src/pandapipes}/pf/internals_toolbox.py (100%) rename {pandapipes => src/pandapipes}/pf/pipeflow_setup.py (100%) rename {pandapipes => src/pandapipes}/pf/result_extraction.py (100%) rename {pandapipes => src/pandapipes}/pipeflow.py (100%) rename {pandapipes => src/pandapipes}/plotting/__init__.py (100%) rename {pandapipes => src/pandapipes}/plotting/collections.py (100%) rename {pandapipes => src/pandapipes}/plotting/generic_geodata.py (100%) rename {pandapipes => src/pandapipes}/plotting/geo.py (100%) rename {pandapipes => src/pandapipes}/plotting/patch_makers.py (100%) rename {pandapipes => src/pandapipes}/plotting/pipeflow_results.py (100%) rename {pandapipes => src/pandapipes}/plotting/plotting_toolbox.py (100%) rename {pandapipes => src/pandapipes}/plotting/simple_plot.py (100%) rename {pandapipes => src/pandapipes}/properties/__init__.py (100%) rename {pandapipes => src/pandapipes}/properties/air/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/air/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/air/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/air/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/air/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/air/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/gas_composition.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_pure/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/gas_composition.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/biomethane_treated/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/carbondioxide/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/carbondioxide/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/carbondioxide/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/carbondioxide/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/ethane/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/ethane/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/ethane/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/ethane/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/fluids.py (100%) rename {pandapipes => src/pandapipes}/properties/hgas/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/hgas/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/hydrogen/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/lgas/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/higher_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/lower_heating_value.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/methane/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/nitrogen/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/nitrogen/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/nitrogen/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/nitrogen/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/oxygen/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/oxygen/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/oxygen/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/oxygen/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/properties/properties_toolbox.py (100%) rename {pandapipes => src/pandapipes}/properties/water/compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/water/density.txt (100%) rename {pandapipes => src/pandapipes}/properties/water/der_compressibility.txt (100%) rename {pandapipes => src/pandapipes}/properties/water/heat_capacity.txt (100%) rename {pandapipes => src/pandapipes}/properties/water/molar_mass.txt (100%) rename {pandapipes => src/pandapipes}/properties/water/viscosity.txt (100%) rename {pandapipes => src/pandapipes}/std_types/__init__.py (100%) rename {pandapipes => src/pandapipes}/std_types/library/Pipe.csv (100%) rename {pandapipes => src/pandapipes}/std_types/library/Pump/P1.csv (100%) rename {pandapipes => src/pandapipes}/std_types/library/Pump/P2.csv (100%) rename {pandapipes => src/pandapipes}/std_types/library/Pump/P3.csv (100%) rename {pandapipes => src/pandapipes}/std_types/std_type_class.py (100%) rename {pandapipes => src/pandapipes}/std_types/std_types.py (100%) rename {pandapipes => src/pandapipes}/test/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/api/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.1.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.1.1.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.1.2.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.2.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.4.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.5.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.6.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.7.0.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.0_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.0_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.1_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.1_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.2_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.2_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.3_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.3_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.4_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.4_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.5_gas.json (100%) rename {pandapipes => src/pandapipes}/test/api/old_versions/example_0.8.5_water.json (100%) rename {pandapipes => src/pandapipes}/test/api/release_cycle/release_control_test_network.py (100%) rename {pandapipes => src/pandapipes}/test/api/release_cycle/release_control_test_sink_profiles.csv (100%) rename {pandapipes => src/pandapipes}/test/api/release_cycle/release_control_test_source_profiles.csv (100%) rename {pandapipes => src/pandapipes}/test/api/test_aux_function.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_circ_pump_mass.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_circ_pump_pressure.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_compressor.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_ext_grid.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_flow_control.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_heat_exchanger.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_mass_storage.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_pipe_results.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_pressure_control.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_pump.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_components/test_valve.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_convert_format.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_create.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_network_tables.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_special_networks.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_std_types.py (100%) rename {pandapipes => src/pandapipes}/test/api/test_time_series.py (100%) rename {pandapipes => src/pandapipes}/test/converter/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/converter/converter_test_files/Exampelonia_mini.csv (100%) rename {pandapipes => src/pandapipes}/test/converter/converter_test_files/Exampelonia_mini_with_2valvepipe.csv (100%) rename {pandapipes => src/pandapipes}/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_closed.csv (100%) rename {pandapipes => src/pandapipes}/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_open.csv (100%) rename {pandapipes => src/pandapipes}/test/converter/test_stanet_converter.py (100%) rename {pandapipes => src/pandapipes}/test/io/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/io/test_file_io.py (100%) rename {pandapipes => src/pandapipes}/test/multinet/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/multinet/test_control_multinet.py (100%) rename {pandapipes => src/pandapipes}/test/multinet/test_time_series_multinet.py (100%) rename {pandapipes => src/pandapipes}/test/networks/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/networks/test_networks.py (100%) rename {pandapipes => src/pandapipes}/test/openmodelica_comparison/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py (100%) rename {pandapipes => src/pandapipes}/test/openmodelica_comparison/test_heat_transfer_openmodelica.py (100%) rename {pandapipes => src/pandapipes}/test/openmodelica_comparison/test_water_openmodelica.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_masche_1load_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_one_pipe_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/ext_grid_p.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/gas_sections_an.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/heat_exchanger_test.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/hydraulics.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/pressure_control_test_analytical.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_circ_pump_mass.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_circ_pump_pressure.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_pressure_control.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_pump.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_sink_profiles.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_time_series_source_profiles.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/data/test_valve.csv (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_inservice.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_non_convergence.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_options.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_pipeflow_analytic_comparison.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_pipeflow_modes.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_time_series.py (100%) rename {pandapipes => src/pandapipes}/test/pipeflow_internals/test_update_matrix.py (100%) rename {pandapipes => src/pandapipes}/test/plotting/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/plotting/test_collections.py (100%) rename {pandapipes => src/pandapipes}/test/plotting/test_generic_coordinates.py (100%) rename {pandapipes => src/pandapipes}/test/plotting/test_pipeflow_results.py (100%) rename {pandapipes => src/pandapipes}/test/plotting/test_simple_collections.py (100%) rename {pandapipes => src/pandapipes}/test/properties/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/properties/test_fluid_specials.py (100%) rename {pandapipes => src/pandapipes}/test/properties/test_properties_toolbox.py (100%) rename {pandapipes => src/pandapipes}/test/pytest.ini (100%) rename {pandapipes => src/pandapipes}/test/run_tests.py (100%) rename {pandapipes => src/pandapipes}/test/stanet_comparison/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/stanet_comparison/pipeflow_stanet_comparison.py (100%) rename {pandapipes => src/pandapipes}/test/stanet_comparison/test_gas_stanet.py (100%) rename {pandapipes => src/pandapipes}/test/stanet_comparison/test_water_stanet.py (100%) rename {pandapipes => src/pandapipes}/test/test_imports.py (100%) rename {pandapipes => src/pandapipes}/test/test_toolbox.py (100%) rename {pandapipes => src/pandapipes}/test/topology/__init__.py (100%) rename {pandapipes => src/pandapipes}/test/topology/test_graph_searches.py (100%) rename {pandapipes => src/pandapipes}/test/topology/test_nxgraph.py (100%) rename {pandapipes => src/pandapipes}/timeseries/__init__.py (100%) rename {pandapipes => src/pandapipes}/timeseries/run_time_series.py (100%) rename {pandapipes => src/pandapipes}/toolbox.py (100%) rename {pandapipes => src/pandapipes}/topology/__init__.py (100%) rename {pandapipes => src/pandapipes}/topology/create_graph.py (100%) rename {pandapipes => src/pandapipes}/topology/graph_searches.py (100%) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index e3bcb5d63..d1ea95dbf 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -102,26 +102,9 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . - python -m pip uninstall pytest-pythonpath - python -m pip install jupyter - python -m pip install --upgrade setuptools - python -m pip install --upgrade pytest - python -m pip install atomicwrites colorama ipython pytest-pythonpath - python -m pip install prompt-toolkit==3.0.41 - python -m pip install Babel==2.13.1 - - name: List all installed packages run: | pip list - - name: Get PYTHONPATH - run: | - echo $PYTHONPATH - - name: Get sys path - run: | - python -c "import sys; print(sys.path)" - - name: List pandapipes packages - run: | - python -c "import sys; import os; from setuptools import find_packages; print(find_packages(where=os.path.join([p for p in sys.path if p.endswith('site-packages')][0], 'pandapipes')))" - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" diff --git a/setup.py b/setup.py index 9e8d009f0..5ad029dc3 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,8 @@ "test": ["pytest", "pytest-xdist", "nbmake"], "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=['pandapipes.' + x for x in find_namespace_packages(where="pandapipes")]+ ['pandapipes'], + packages=find_namespace_packages(where='src'), + package_dir={"":"src"}, include_package_data=True, classifiers=classifiers ) diff --git a/pandapipes/__init__.py b/src/pandapipes/__init__.py similarity index 100% rename from pandapipes/__init__.py rename to src/pandapipes/__init__.py diff --git a/pandapipes/component_models/__init__.py b/src/pandapipes/component_models/__init__.py similarity index 100% rename from pandapipes/component_models/__init__.py rename to src/pandapipes/component_models/__init__.py diff --git a/pandapipes/component_models/abstract_models/__init__.py b/src/pandapipes/component_models/abstract_models/__init__.py similarity index 100% rename from pandapipes/component_models/abstract_models/__init__.py rename to src/pandapipes/component_models/abstract_models/__init__.py diff --git a/pandapipes/component_models/abstract_models/base_component.py b/src/pandapipes/component_models/abstract_models/base_component.py similarity index 100% rename from pandapipes/component_models/abstract_models/base_component.py rename to src/pandapipes/component_models/abstract_models/base_component.py diff --git a/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/branch_models.py rename to src/pandapipes/component_models/abstract_models/branch_models.py diff --git a/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/branch_w_internals_models.py rename to src/pandapipes/component_models/abstract_models/branch_w_internals_models.py diff --git a/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/branch_wo_internals_models.py rename to src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py diff --git a/pandapipes/component_models/abstract_models/branch_wzerolength_models.py b/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/branch_wzerolength_models.py rename to src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py diff --git a/pandapipes/component_models/abstract_models/circulation_pump.py b/src/pandapipes/component_models/abstract_models/circulation_pump.py similarity index 100% rename from pandapipes/component_models/abstract_models/circulation_pump.py rename to src/pandapipes/component_models/abstract_models/circulation_pump.py diff --git a/pandapipes/component_models/abstract_models/const_flow_models.py b/src/pandapipes/component_models/abstract_models/const_flow_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/const_flow_models.py rename to src/pandapipes/component_models/abstract_models/const_flow_models.py diff --git a/pandapipes/component_models/abstract_models/node_element_models.py b/src/pandapipes/component_models/abstract_models/node_element_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/node_element_models.py rename to src/pandapipes/component_models/abstract_models/node_element_models.py diff --git a/pandapipes/component_models/abstract_models/node_models.py b/src/pandapipes/component_models/abstract_models/node_models.py similarity index 100% rename from pandapipes/component_models/abstract_models/node_models.py rename to src/pandapipes/component_models/abstract_models/node_models.py diff --git a/pandapipes/component_models/circulation_pump_mass_component.py b/src/pandapipes/component_models/circulation_pump_mass_component.py similarity index 100% rename from pandapipes/component_models/circulation_pump_mass_component.py rename to src/pandapipes/component_models/circulation_pump_mass_component.py diff --git a/pandapipes/component_models/circulation_pump_pressure_component.py b/src/pandapipes/component_models/circulation_pump_pressure_component.py similarity index 100% rename from pandapipes/component_models/circulation_pump_pressure_component.py rename to src/pandapipes/component_models/circulation_pump_pressure_component.py diff --git a/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py similarity index 100% rename from pandapipes/component_models/component_toolbox.py rename to src/pandapipes/component_models/component_toolbox.py diff --git a/pandapipes/component_models/compressor_component.py b/src/pandapipes/component_models/compressor_component.py similarity index 100% rename from pandapipes/component_models/compressor_component.py rename to src/pandapipes/component_models/compressor_component.py diff --git a/pandapipes/component_models/ext_grid_component.py b/src/pandapipes/component_models/ext_grid_component.py similarity index 100% rename from pandapipes/component_models/ext_grid_component.py rename to src/pandapipes/component_models/ext_grid_component.py diff --git a/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py similarity index 100% rename from pandapipes/component_models/flow_control_component.py rename to src/pandapipes/component_models/flow_control_component.py diff --git a/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py similarity index 100% rename from pandapipes/component_models/heat_exchanger_component.py rename to src/pandapipes/component_models/heat_exchanger_component.py diff --git a/pandapipes/component_models/junction_component.py b/src/pandapipes/component_models/junction_component.py similarity index 100% rename from pandapipes/component_models/junction_component.py rename to src/pandapipes/component_models/junction_component.py diff --git a/pandapipes/component_models/mass_storage_component.py b/src/pandapipes/component_models/mass_storage_component.py similarity index 100% rename from pandapipes/component_models/mass_storage_component.py rename to src/pandapipes/component_models/mass_storage_component.py diff --git a/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py similarity index 100% rename from pandapipes/component_models/pipe_component.py rename to src/pandapipes/component_models/pipe_component.py diff --git a/pandapipes/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py similarity index 100% rename from pandapipes/component_models/pressure_control_component.py rename to src/pandapipes/component_models/pressure_control_component.py diff --git a/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py similarity index 100% rename from pandapipes/component_models/pump_component.py rename to src/pandapipes/component_models/pump_component.py diff --git a/pandapipes/component_models/sink_component.py b/src/pandapipes/component_models/sink_component.py similarity index 100% rename from pandapipes/component_models/sink_component.py rename to src/pandapipes/component_models/sink_component.py diff --git a/pandapipes/component_models/source_component.py b/src/pandapipes/component_models/source_component.py similarity index 100% rename from pandapipes/component_models/source_component.py rename to src/pandapipes/component_models/source_component.py diff --git a/pandapipes/component_models/valve_component.py b/src/pandapipes/component_models/valve_component.py similarity index 100% rename from pandapipes/component_models/valve_component.py rename to src/pandapipes/component_models/valve_component.py diff --git a/pandapipes/constants.py b/src/pandapipes/constants.py similarity index 100% rename from pandapipes/constants.py rename to src/pandapipes/constants.py diff --git a/pandapipes/control/__init__.py b/src/pandapipes/control/__init__.py similarity index 100% rename from pandapipes/control/__init__.py rename to src/pandapipes/control/__init__.py diff --git a/pandapipes/control/run_control.py b/src/pandapipes/control/run_control.py similarity index 100% rename from pandapipes/control/run_control.py rename to src/pandapipes/control/run_control.py diff --git a/pandapipes/converter/__init__.py b/src/pandapipes/converter/__init__.py similarity index 100% rename from pandapipes/converter/__init__.py rename to src/pandapipes/converter/__init__.py diff --git a/pandapipes/converter/stanet/__init__.py b/src/pandapipes/converter/stanet/__init__.py similarity index 100% rename from pandapipes/converter/stanet/__init__.py rename to src/pandapipes/converter/stanet/__init__.py diff --git a/pandapipes/converter/stanet/data_cleaning.py b/src/pandapipes/converter/stanet/data_cleaning.py similarity index 100% rename from pandapipes/converter/stanet/data_cleaning.py rename to src/pandapipes/converter/stanet/data_cleaning.py diff --git a/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py similarity index 100% rename from pandapipes/converter/stanet/preparing_steps.py rename to src/pandapipes/converter/stanet/preparing_steps.py diff --git a/pandapipes/converter/stanet/stanet2pandapipes.py b/src/pandapipes/converter/stanet/stanet2pandapipes.py similarity index 100% rename from pandapipes/converter/stanet/stanet2pandapipes.py rename to src/pandapipes/converter/stanet/stanet2pandapipes.py diff --git a/pandapipes/converter/stanet/table_creation.py b/src/pandapipes/converter/stanet/table_creation.py similarity index 100% rename from pandapipes/converter/stanet/table_creation.py rename to src/pandapipes/converter/stanet/table_creation.py diff --git a/pandapipes/converter/stanet/valve_pipe_component/__init__.py b/src/pandapipes/converter/stanet/valve_pipe_component/__init__.py similarity index 100% rename from pandapipes/converter/stanet/valve_pipe_component/__init__.py rename to src/pandapipes/converter/stanet/valve_pipe_component/__init__.py diff --git a/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py b/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py similarity index 100% rename from pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py rename to src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py diff --git a/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py similarity index 100% rename from pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py rename to src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py diff --git a/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py similarity index 100% rename from pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py rename to src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py diff --git a/pandapipes/create.py b/src/pandapipes/create.py similarity index 100% rename from pandapipes/create.py rename to src/pandapipes/create.py diff --git a/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py similarity index 100% rename from pandapipes/idx_branch.py rename to src/pandapipes/idx_branch.py diff --git a/pandapipes/idx_node.py b/src/pandapipes/idx_node.py similarity index 100% rename from pandapipes/idx_node.py rename to src/pandapipes/idx_node.py diff --git a/pandapipes/io/__init__.py b/src/pandapipes/io/__init__.py similarity index 100% rename from pandapipes/io/__init__.py rename to src/pandapipes/io/__init__.py diff --git a/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py similarity index 100% rename from pandapipes/io/convert_format.py rename to src/pandapipes/io/convert_format.py diff --git a/pandapipes/io/file_io.py b/src/pandapipes/io/file_io.py similarity index 100% rename from pandapipes/io/file_io.py rename to src/pandapipes/io/file_io.py diff --git a/pandapipes/io/io_utils.py b/src/pandapipes/io/io_utils.py similarity index 100% rename from pandapipes/io/io_utils.py rename to src/pandapipes/io/io_utils.py diff --git a/pandapipes/multinet/__init__.py b/src/pandapipes/multinet/__init__.py similarity index 100% rename from pandapipes/multinet/__init__.py rename to src/pandapipes/multinet/__init__.py diff --git a/pandapipes/multinet/control/__init__.py b/src/pandapipes/multinet/control/__init__.py similarity index 100% rename from pandapipes/multinet/control/__init__.py rename to src/pandapipes/multinet/control/__init__.py diff --git a/pandapipes/multinet/control/controller/__init__.py b/src/pandapipes/multinet/control/controller/__init__.py similarity index 100% rename from pandapipes/multinet/control/controller/__init__.py rename to src/pandapipes/multinet/control/controller/__init__.py diff --git a/pandapipes/multinet/control/controller/multinet_control.py b/src/pandapipes/multinet/control/controller/multinet_control.py similarity index 100% rename from pandapipes/multinet/control/controller/multinet_control.py rename to src/pandapipes/multinet/control/controller/multinet_control.py diff --git a/pandapipes/multinet/control/run_control_multinet.py b/src/pandapipes/multinet/control/run_control_multinet.py similarity index 100% rename from pandapipes/multinet/control/run_control_multinet.py rename to src/pandapipes/multinet/control/run_control_multinet.py diff --git a/pandapipes/multinet/create_multinet.py b/src/pandapipes/multinet/create_multinet.py similarity index 100% rename from pandapipes/multinet/create_multinet.py rename to src/pandapipes/multinet/create_multinet.py diff --git a/pandapipes/multinet/multinet.py b/src/pandapipes/multinet/multinet.py similarity index 100% rename from pandapipes/multinet/multinet.py rename to src/pandapipes/multinet/multinet.py diff --git a/pandapipes/multinet/timeseries/__init__.py b/src/pandapipes/multinet/timeseries/__init__.py similarity index 100% rename from pandapipes/multinet/timeseries/__init__.py rename to src/pandapipes/multinet/timeseries/__init__.py diff --git a/pandapipes/multinet/timeseries/run_time_series_multinet.py b/src/pandapipes/multinet/timeseries/run_time_series_multinet.py similarity index 100% rename from pandapipes/multinet/timeseries/run_time_series_multinet.py rename to src/pandapipes/multinet/timeseries/run_time_series_multinet.py diff --git a/pandapipes/networks/__init__.py b/src/pandapipes/networks/__init__.py similarity index 100% rename from pandapipes/networks/__init__.py rename to src/pandapipes/networks/__init__.py diff --git a/pandapipes/networks/network_files/gas_net_schutterwald_1bar.json b/src/pandapipes/networks/network_files/gas_net_schutterwald_1bar.json similarity index 100% rename from pandapipes/networks/network_files/gas_net_schutterwald_1bar.json rename to src/pandapipes/networks/network_files/gas_net_schutterwald_1bar.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta_2sinks.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta_2sinks.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta_2sinks.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/delta_2sinks.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/heights.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/heights.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/heights.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/heights.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_pipe.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_pipe.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_pipe.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_pipe.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_source.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_source.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_source.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/one_source.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/section_variation.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/section_variation.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/section_variation.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/section_variation.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/t_cross.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/t_cross.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/t_cross.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/t_cross.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/two_pipes.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/two_pipes.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/two_pipes.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/heat_transfer_cases/two_pipes.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/mixed_net.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/mixed_net.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/mixed_net.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/mixed_net.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/versatility.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/versatility.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/versatility.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/combined_networks/versatility.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/delta.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/delta.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/delta.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/delta.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/heights.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/heights.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/heights.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/heights.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/pumps.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/pumps.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/pumps.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/pumps.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/two_valves.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/two_valves.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/two_valves.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/meshed_networks/two_valves.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_1.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_1.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_1.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_1.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_2.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_2.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_2.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_2.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_3.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_3.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_3.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/one_pipe/pipe_3.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/cross_3ext.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/cross_3ext.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/cross_3ext.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/cross_3ext.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/strand_net.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/strand_net.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/strand_net.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/strand_net.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pipes.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pipes.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pipes.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pipes.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pumps.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pumps.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pumps.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/strand_net/two_pumps.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/t_cross.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/t_cross.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/t_cross.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/t_cross.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/valves.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/valves.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/valves.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/t_cross/valves.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/two_pressure_junctions/two_pipes.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/two_pressure_junctions/two_pipes.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/two_pressure_junctions/two_pipes.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_colebrook/two_pressure_junctions/two_pipes.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/mixed_net.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/mixed_net.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/mixed_net.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/mixed_net.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/versatility.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/versatility.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/versatility.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/combined_networks/versatility.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/delta.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/delta.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/delta.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/delta.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/heights.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/heights.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/heights.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/heights.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/one_valve_stanet.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/one_valve_stanet.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/one_valve_stanet.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/one_valve_stanet.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/pumps.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/pumps.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/pumps.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/pumps.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/two_valves.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/two_valves.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/two_valves.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/meshed_networks/two_valves.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_1.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_1.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_1.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_1.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_2.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_2.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_2.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_2.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_3.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_3.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_3.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/one_pipe/pipe_3.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/cross_3ext.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/cross_3ext.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/cross_3ext.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/cross_3ext.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation1.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation1.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation1.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation1.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation2.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation2.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation2.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/strand_net_stanet_variation2.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pipes.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pipes.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pipes.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pipes.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pumps.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pumps.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pumps.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/strand_net/two_pumps.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/t_cross.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/t_cross.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/t_cross.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/t_cross.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/valves.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/valves.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/valves.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/t_cross/valves.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/one_pipe_stanet.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/one_pipe_stanet.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/one_pipe_stanet.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/one_pipe_stanet.json diff --git a/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/two_pipes.json b/src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/two_pipes.json similarity index 100% rename from pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/two_pipes.json rename to src/pandapipes/networks/network_files/openmodelica_test_networks/water_cases_swamee-jain/two_pressure_junctions/two_pipes.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural1--0-sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural2--0-sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-rural3--0-sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb4--0-sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-semiurb5--0-sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-no_sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-no_sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-no_sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-no_sw.json diff --git a/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-sw.json b/src/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-sw.json similarity index 100% rename from pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-sw.json rename to src/pandapipes/networks/network_files/simbench_test_networks/1-LV-urban6--0-sw.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/parallel_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/versatility_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/versatility_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/versatility_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/combined_networks/versatility_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/delta_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/delta_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/delta_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/delta_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/pumps_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/pumps_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/pumps_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/pumps_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/square_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/meshed_networks/two_valves_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_1_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/one_pipe/pipe_2_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/pump_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/pump_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/pump_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/pump_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/strand_net/two_pipes_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross1_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/t_cross/t_cross2_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/gas_cases/two_pressure_junctions/H_net_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/district_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/combined_networks/versatility_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/delta_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/delta_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/delta_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/delta_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/pumps_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/pumps_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/pumps_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/pumps_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/meshed_networks/two_valves_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_1_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_2_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/one_pipe/pipe_3_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/cross_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/cross_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/cross_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/cross_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/pump_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/pump_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/pump_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/pump_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/strand_net_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/strand_net/two_pipes_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/t_cross/t_cross_PC.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_N.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_N.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_N.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_N.json diff --git a/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_PC.json b/src/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_PC.json similarity index 100% rename from pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_PC.json rename to src/pandapipes/networks/network_files/stanet_test_networks/water_cases/two_pressure_junctions/two_pipes_PC.json diff --git a/pandapipes/networks/nw_aux.py b/src/pandapipes/networks/nw_aux.py similarity index 100% rename from pandapipes/networks/nw_aux.py rename to src/pandapipes/networks/nw_aux.py diff --git a/pandapipes/networks/simple_gas_networks.py b/src/pandapipes/networks/simple_gas_networks.py similarity index 100% rename from pandapipes/networks/simple_gas_networks.py rename to src/pandapipes/networks/simple_gas_networks.py diff --git a/pandapipes/networks/simple_heat_transfer_networks.py b/src/pandapipes/networks/simple_heat_transfer_networks.py similarity index 100% rename from pandapipes/networks/simple_heat_transfer_networks.py rename to src/pandapipes/networks/simple_heat_transfer_networks.py diff --git a/pandapipes/networks/simple_water_networks.py b/src/pandapipes/networks/simple_water_networks.py similarity index 100% rename from pandapipes/networks/simple_water_networks.py rename to src/pandapipes/networks/simple_water_networks.py diff --git a/pandapipes/pandapipes_net.py b/src/pandapipes/pandapipes_net.py similarity index 100% rename from pandapipes/pandapipes_net.py rename to src/pandapipes/pandapipes_net.py diff --git a/pandapipes/pf/__init__.py b/src/pandapipes/pf/__init__.py similarity index 100% rename from pandapipes/pf/__init__.py rename to src/pandapipes/pf/__init__.py diff --git a/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py similarity index 100% rename from pandapipes/pf/build_system_matrix.py rename to src/pandapipes/pf/build_system_matrix.py diff --git a/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py similarity index 100% rename from pandapipes/pf/derivative_calculation.py rename to src/pandapipes/pf/derivative_calculation.py diff --git a/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py similarity index 100% rename from pandapipes/pf/derivative_toolbox.py rename to src/pandapipes/pf/derivative_toolbox.py diff --git a/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py similarity index 100% rename from pandapipes/pf/derivative_toolbox_numba.py rename to src/pandapipes/pf/derivative_toolbox_numba.py diff --git a/pandapipes/pf/internals_toolbox.py b/src/pandapipes/pf/internals_toolbox.py similarity index 100% rename from pandapipes/pf/internals_toolbox.py rename to src/pandapipes/pf/internals_toolbox.py diff --git a/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py similarity index 100% rename from pandapipes/pf/pipeflow_setup.py rename to src/pandapipes/pf/pipeflow_setup.py diff --git a/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py similarity index 100% rename from pandapipes/pf/result_extraction.py rename to src/pandapipes/pf/result_extraction.py diff --git a/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py similarity index 100% rename from pandapipes/pipeflow.py rename to src/pandapipes/pipeflow.py diff --git a/pandapipes/plotting/__init__.py b/src/pandapipes/plotting/__init__.py similarity index 100% rename from pandapipes/plotting/__init__.py rename to src/pandapipes/plotting/__init__.py diff --git a/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py similarity index 100% rename from pandapipes/plotting/collections.py rename to src/pandapipes/plotting/collections.py diff --git a/pandapipes/plotting/generic_geodata.py b/src/pandapipes/plotting/generic_geodata.py similarity index 100% rename from pandapipes/plotting/generic_geodata.py rename to src/pandapipes/plotting/generic_geodata.py diff --git a/pandapipes/plotting/geo.py b/src/pandapipes/plotting/geo.py similarity index 100% rename from pandapipes/plotting/geo.py rename to src/pandapipes/plotting/geo.py diff --git a/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py similarity index 100% rename from pandapipes/plotting/patch_makers.py rename to src/pandapipes/plotting/patch_makers.py diff --git a/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py similarity index 100% rename from pandapipes/plotting/pipeflow_results.py rename to src/pandapipes/plotting/pipeflow_results.py diff --git a/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py similarity index 100% rename from pandapipes/plotting/plotting_toolbox.py rename to src/pandapipes/plotting/plotting_toolbox.py diff --git a/pandapipes/plotting/simple_plot.py b/src/pandapipes/plotting/simple_plot.py similarity index 100% rename from pandapipes/plotting/simple_plot.py rename to src/pandapipes/plotting/simple_plot.py diff --git a/pandapipes/properties/__init__.py b/src/pandapipes/properties/__init__.py similarity index 100% rename from pandapipes/properties/__init__.py rename to src/pandapipes/properties/__init__.py diff --git a/pandapipes/properties/air/compressibility.txt b/src/pandapipes/properties/air/compressibility.txt similarity index 100% rename from pandapipes/properties/air/compressibility.txt rename to src/pandapipes/properties/air/compressibility.txt diff --git a/pandapipes/properties/air/density.txt b/src/pandapipes/properties/air/density.txt similarity index 100% rename from pandapipes/properties/air/density.txt rename to src/pandapipes/properties/air/density.txt diff --git a/pandapipes/properties/air/der_compressibility.txt b/src/pandapipes/properties/air/der_compressibility.txt similarity index 100% rename from pandapipes/properties/air/der_compressibility.txt rename to src/pandapipes/properties/air/der_compressibility.txt diff --git a/pandapipes/properties/air/heat_capacity.txt b/src/pandapipes/properties/air/heat_capacity.txt similarity index 100% rename from pandapipes/properties/air/heat_capacity.txt rename to src/pandapipes/properties/air/heat_capacity.txt diff --git a/pandapipes/properties/air/molar_mass.txt b/src/pandapipes/properties/air/molar_mass.txt similarity index 100% rename from pandapipes/properties/air/molar_mass.txt rename to src/pandapipes/properties/air/molar_mass.txt diff --git a/pandapipes/properties/air/viscosity.txt b/src/pandapipes/properties/air/viscosity.txt similarity index 100% rename from pandapipes/properties/air/viscosity.txt rename to src/pandapipes/properties/air/viscosity.txt diff --git a/pandapipes/properties/biomethane_pure/compressibility.txt b/src/pandapipes/properties/biomethane_pure/compressibility.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/compressibility.txt rename to src/pandapipes/properties/biomethane_pure/compressibility.txt diff --git a/pandapipes/properties/biomethane_pure/density.txt b/src/pandapipes/properties/biomethane_pure/density.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/density.txt rename to src/pandapipes/properties/biomethane_pure/density.txt diff --git a/pandapipes/properties/biomethane_pure/der_compressibility.txt b/src/pandapipes/properties/biomethane_pure/der_compressibility.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/der_compressibility.txt rename to src/pandapipes/properties/biomethane_pure/der_compressibility.txt diff --git a/pandapipes/properties/biomethane_pure/gas_composition.txt b/src/pandapipes/properties/biomethane_pure/gas_composition.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/gas_composition.txt rename to src/pandapipes/properties/biomethane_pure/gas_composition.txt diff --git a/pandapipes/properties/biomethane_pure/heat_capacity.txt b/src/pandapipes/properties/biomethane_pure/heat_capacity.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/heat_capacity.txt rename to src/pandapipes/properties/biomethane_pure/heat_capacity.txt diff --git a/pandapipes/properties/biomethane_pure/higher_heating_value.txt b/src/pandapipes/properties/biomethane_pure/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/higher_heating_value.txt rename to src/pandapipes/properties/biomethane_pure/higher_heating_value.txt diff --git a/pandapipes/properties/biomethane_pure/lower_heating_value.txt b/src/pandapipes/properties/biomethane_pure/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/lower_heating_value.txt rename to src/pandapipes/properties/biomethane_pure/lower_heating_value.txt diff --git a/pandapipes/properties/biomethane_pure/molar_mass.txt b/src/pandapipes/properties/biomethane_pure/molar_mass.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/molar_mass.txt rename to src/pandapipes/properties/biomethane_pure/molar_mass.txt diff --git a/pandapipes/properties/biomethane_pure/viscosity.txt b/src/pandapipes/properties/biomethane_pure/viscosity.txt similarity index 100% rename from pandapipes/properties/biomethane_pure/viscosity.txt rename to src/pandapipes/properties/biomethane_pure/viscosity.txt diff --git a/pandapipes/properties/biomethane_treated/compressibility.txt b/src/pandapipes/properties/biomethane_treated/compressibility.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/compressibility.txt rename to src/pandapipes/properties/biomethane_treated/compressibility.txt diff --git a/pandapipes/properties/biomethane_treated/density.txt b/src/pandapipes/properties/biomethane_treated/density.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/density.txt rename to src/pandapipes/properties/biomethane_treated/density.txt diff --git a/pandapipes/properties/biomethane_treated/der_compressibility.txt b/src/pandapipes/properties/biomethane_treated/der_compressibility.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/der_compressibility.txt rename to src/pandapipes/properties/biomethane_treated/der_compressibility.txt diff --git a/pandapipes/properties/biomethane_treated/gas_composition.txt b/src/pandapipes/properties/biomethane_treated/gas_composition.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/gas_composition.txt rename to src/pandapipes/properties/biomethane_treated/gas_composition.txt diff --git a/pandapipes/properties/biomethane_treated/heat_capacity.txt b/src/pandapipes/properties/biomethane_treated/heat_capacity.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/heat_capacity.txt rename to src/pandapipes/properties/biomethane_treated/heat_capacity.txt diff --git a/pandapipes/properties/biomethane_treated/higher_heating_value.txt b/src/pandapipes/properties/biomethane_treated/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/higher_heating_value.txt rename to src/pandapipes/properties/biomethane_treated/higher_heating_value.txt diff --git a/pandapipes/properties/biomethane_treated/lower_heating_value.txt b/src/pandapipes/properties/biomethane_treated/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/lower_heating_value.txt rename to src/pandapipes/properties/biomethane_treated/lower_heating_value.txt diff --git a/pandapipes/properties/biomethane_treated/molar_mass.txt b/src/pandapipes/properties/biomethane_treated/molar_mass.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/molar_mass.txt rename to src/pandapipes/properties/biomethane_treated/molar_mass.txt diff --git a/pandapipes/properties/biomethane_treated/viscosity.txt b/src/pandapipes/properties/biomethane_treated/viscosity.txt similarity index 100% rename from pandapipes/properties/biomethane_treated/viscosity.txt rename to src/pandapipes/properties/biomethane_treated/viscosity.txt diff --git a/pandapipes/properties/carbondioxide/density.txt b/src/pandapipes/properties/carbondioxide/density.txt similarity index 100% rename from pandapipes/properties/carbondioxide/density.txt rename to src/pandapipes/properties/carbondioxide/density.txt diff --git a/pandapipes/properties/carbondioxide/heat_capacity.txt b/src/pandapipes/properties/carbondioxide/heat_capacity.txt similarity index 100% rename from pandapipes/properties/carbondioxide/heat_capacity.txt rename to src/pandapipes/properties/carbondioxide/heat_capacity.txt diff --git a/pandapipes/properties/carbondioxide/molar_mass.txt b/src/pandapipes/properties/carbondioxide/molar_mass.txt similarity index 100% rename from pandapipes/properties/carbondioxide/molar_mass.txt rename to src/pandapipes/properties/carbondioxide/molar_mass.txt diff --git a/pandapipes/properties/carbondioxide/viscosity.txt b/src/pandapipes/properties/carbondioxide/viscosity.txt similarity index 100% rename from pandapipes/properties/carbondioxide/viscosity.txt rename to src/pandapipes/properties/carbondioxide/viscosity.txt diff --git a/pandapipes/properties/ethane/density.txt b/src/pandapipes/properties/ethane/density.txt similarity index 100% rename from pandapipes/properties/ethane/density.txt rename to src/pandapipes/properties/ethane/density.txt diff --git a/pandapipes/properties/ethane/heat_capacity.txt b/src/pandapipes/properties/ethane/heat_capacity.txt similarity index 100% rename from pandapipes/properties/ethane/heat_capacity.txt rename to src/pandapipes/properties/ethane/heat_capacity.txt diff --git a/pandapipes/properties/ethane/molar_mass.txt b/src/pandapipes/properties/ethane/molar_mass.txt similarity index 100% rename from pandapipes/properties/ethane/molar_mass.txt rename to src/pandapipes/properties/ethane/molar_mass.txt diff --git a/pandapipes/properties/ethane/viscosity.txt b/src/pandapipes/properties/ethane/viscosity.txt similarity index 100% rename from pandapipes/properties/ethane/viscosity.txt rename to src/pandapipes/properties/ethane/viscosity.txt diff --git a/pandapipes/properties/fluids.py b/src/pandapipes/properties/fluids.py similarity index 100% rename from pandapipes/properties/fluids.py rename to src/pandapipes/properties/fluids.py diff --git a/pandapipes/properties/hgas/compressibility.txt b/src/pandapipes/properties/hgas/compressibility.txt similarity index 100% rename from pandapipes/properties/hgas/compressibility.txt rename to src/pandapipes/properties/hgas/compressibility.txt diff --git a/pandapipes/properties/hgas/density.txt b/src/pandapipes/properties/hgas/density.txt similarity index 100% rename from pandapipes/properties/hgas/density.txt rename to src/pandapipes/properties/hgas/density.txt diff --git a/pandapipes/properties/hgas/der_compressibility.txt b/src/pandapipes/properties/hgas/der_compressibility.txt similarity index 100% rename from pandapipes/properties/hgas/der_compressibility.txt rename to src/pandapipes/properties/hgas/der_compressibility.txt diff --git a/pandapipes/properties/hgas/heat_capacity.txt b/src/pandapipes/properties/hgas/heat_capacity.txt similarity index 100% rename from pandapipes/properties/hgas/heat_capacity.txt rename to src/pandapipes/properties/hgas/heat_capacity.txt diff --git a/pandapipes/properties/hgas/higher_heating_value.txt b/src/pandapipes/properties/hgas/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/hgas/higher_heating_value.txt rename to src/pandapipes/properties/hgas/higher_heating_value.txt diff --git a/pandapipes/properties/hgas/lower_heating_value.txt b/src/pandapipes/properties/hgas/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/hgas/lower_heating_value.txt rename to src/pandapipes/properties/hgas/lower_heating_value.txt diff --git a/pandapipes/properties/hgas/molar_mass.txt b/src/pandapipes/properties/hgas/molar_mass.txt similarity index 100% rename from pandapipes/properties/hgas/molar_mass.txt rename to src/pandapipes/properties/hgas/molar_mass.txt diff --git a/pandapipes/properties/hgas/viscosity.txt b/src/pandapipes/properties/hgas/viscosity.txt similarity index 100% rename from pandapipes/properties/hgas/viscosity.txt rename to src/pandapipes/properties/hgas/viscosity.txt diff --git a/pandapipes/properties/hydrogen/compressibility.txt b/src/pandapipes/properties/hydrogen/compressibility.txt similarity index 100% rename from pandapipes/properties/hydrogen/compressibility.txt rename to src/pandapipes/properties/hydrogen/compressibility.txt diff --git a/pandapipes/properties/hydrogen/density.txt b/src/pandapipes/properties/hydrogen/density.txt similarity index 100% rename from pandapipes/properties/hydrogen/density.txt rename to src/pandapipes/properties/hydrogen/density.txt diff --git a/pandapipes/properties/hydrogen/der_compressibility.txt b/src/pandapipes/properties/hydrogen/der_compressibility.txt similarity index 100% rename from pandapipes/properties/hydrogen/der_compressibility.txt rename to src/pandapipes/properties/hydrogen/der_compressibility.txt diff --git a/pandapipes/properties/hydrogen/heat_capacity.txt b/src/pandapipes/properties/hydrogen/heat_capacity.txt similarity index 100% rename from pandapipes/properties/hydrogen/heat_capacity.txt rename to src/pandapipes/properties/hydrogen/heat_capacity.txt diff --git a/pandapipes/properties/hydrogen/higher_heating_value.txt b/src/pandapipes/properties/hydrogen/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/hydrogen/higher_heating_value.txt rename to src/pandapipes/properties/hydrogen/higher_heating_value.txt diff --git a/pandapipes/properties/hydrogen/lower_heating_value.txt b/src/pandapipes/properties/hydrogen/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/hydrogen/lower_heating_value.txt rename to src/pandapipes/properties/hydrogen/lower_heating_value.txt diff --git a/pandapipes/properties/hydrogen/molar_mass.txt b/src/pandapipes/properties/hydrogen/molar_mass.txt similarity index 100% rename from pandapipes/properties/hydrogen/molar_mass.txt rename to src/pandapipes/properties/hydrogen/molar_mass.txt diff --git a/pandapipes/properties/hydrogen/viscosity.txt b/src/pandapipes/properties/hydrogen/viscosity.txt similarity index 100% rename from pandapipes/properties/hydrogen/viscosity.txt rename to src/pandapipes/properties/hydrogen/viscosity.txt diff --git a/pandapipes/properties/lgas/compressibility.txt b/src/pandapipes/properties/lgas/compressibility.txt similarity index 100% rename from pandapipes/properties/lgas/compressibility.txt rename to src/pandapipes/properties/lgas/compressibility.txt diff --git a/pandapipes/properties/lgas/density.txt b/src/pandapipes/properties/lgas/density.txt similarity index 100% rename from pandapipes/properties/lgas/density.txt rename to src/pandapipes/properties/lgas/density.txt diff --git a/pandapipes/properties/lgas/der_compressibility.txt b/src/pandapipes/properties/lgas/der_compressibility.txt similarity index 100% rename from pandapipes/properties/lgas/der_compressibility.txt rename to src/pandapipes/properties/lgas/der_compressibility.txt diff --git a/pandapipes/properties/lgas/heat_capacity.txt b/src/pandapipes/properties/lgas/heat_capacity.txt similarity index 100% rename from pandapipes/properties/lgas/heat_capacity.txt rename to src/pandapipes/properties/lgas/heat_capacity.txt diff --git a/pandapipes/properties/lgas/higher_heating_value.txt b/src/pandapipes/properties/lgas/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/lgas/higher_heating_value.txt rename to src/pandapipes/properties/lgas/higher_heating_value.txt diff --git a/pandapipes/properties/lgas/lower_heating_value.txt b/src/pandapipes/properties/lgas/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/lgas/lower_heating_value.txt rename to src/pandapipes/properties/lgas/lower_heating_value.txt diff --git a/pandapipes/properties/lgas/molar_mass.txt b/src/pandapipes/properties/lgas/molar_mass.txt similarity index 100% rename from pandapipes/properties/lgas/molar_mass.txt rename to src/pandapipes/properties/lgas/molar_mass.txt diff --git a/pandapipes/properties/lgas/viscosity.txt b/src/pandapipes/properties/lgas/viscosity.txt similarity index 100% rename from pandapipes/properties/lgas/viscosity.txt rename to src/pandapipes/properties/lgas/viscosity.txt diff --git a/pandapipes/properties/methane/compressibility.txt b/src/pandapipes/properties/methane/compressibility.txt similarity index 100% rename from pandapipes/properties/methane/compressibility.txt rename to src/pandapipes/properties/methane/compressibility.txt diff --git a/pandapipes/properties/methane/density.txt b/src/pandapipes/properties/methane/density.txt similarity index 100% rename from pandapipes/properties/methane/density.txt rename to src/pandapipes/properties/methane/density.txt diff --git a/pandapipes/properties/methane/der_compressibility.txt b/src/pandapipes/properties/methane/der_compressibility.txt similarity index 100% rename from pandapipes/properties/methane/der_compressibility.txt rename to src/pandapipes/properties/methane/der_compressibility.txt diff --git a/pandapipes/properties/methane/heat_capacity.txt b/src/pandapipes/properties/methane/heat_capacity.txt similarity index 100% rename from pandapipes/properties/methane/heat_capacity.txt rename to src/pandapipes/properties/methane/heat_capacity.txt diff --git a/pandapipes/properties/methane/higher_heating_value.txt b/src/pandapipes/properties/methane/higher_heating_value.txt similarity index 100% rename from pandapipes/properties/methane/higher_heating_value.txt rename to src/pandapipes/properties/methane/higher_heating_value.txt diff --git a/pandapipes/properties/methane/lower_heating_value.txt b/src/pandapipes/properties/methane/lower_heating_value.txt similarity index 100% rename from pandapipes/properties/methane/lower_heating_value.txt rename to src/pandapipes/properties/methane/lower_heating_value.txt diff --git a/pandapipes/properties/methane/molar_mass.txt b/src/pandapipes/properties/methane/molar_mass.txt similarity index 100% rename from pandapipes/properties/methane/molar_mass.txt rename to src/pandapipes/properties/methane/molar_mass.txt diff --git a/pandapipes/properties/methane/viscosity.txt b/src/pandapipes/properties/methane/viscosity.txt similarity index 100% rename from pandapipes/properties/methane/viscosity.txt rename to src/pandapipes/properties/methane/viscosity.txt diff --git a/pandapipes/properties/nitrogen/density.txt b/src/pandapipes/properties/nitrogen/density.txt similarity index 100% rename from pandapipes/properties/nitrogen/density.txt rename to src/pandapipes/properties/nitrogen/density.txt diff --git a/pandapipes/properties/nitrogen/heat_capacity.txt b/src/pandapipes/properties/nitrogen/heat_capacity.txt similarity index 100% rename from pandapipes/properties/nitrogen/heat_capacity.txt rename to src/pandapipes/properties/nitrogen/heat_capacity.txt diff --git a/pandapipes/properties/nitrogen/molar_mass.txt b/src/pandapipes/properties/nitrogen/molar_mass.txt similarity index 100% rename from pandapipes/properties/nitrogen/molar_mass.txt rename to src/pandapipes/properties/nitrogen/molar_mass.txt diff --git a/pandapipes/properties/nitrogen/viscosity.txt b/src/pandapipes/properties/nitrogen/viscosity.txt similarity index 100% rename from pandapipes/properties/nitrogen/viscosity.txt rename to src/pandapipes/properties/nitrogen/viscosity.txt diff --git a/pandapipes/properties/oxygen/density.txt b/src/pandapipes/properties/oxygen/density.txt similarity index 100% rename from pandapipes/properties/oxygen/density.txt rename to src/pandapipes/properties/oxygen/density.txt diff --git a/pandapipes/properties/oxygen/heat_capacity.txt b/src/pandapipes/properties/oxygen/heat_capacity.txt similarity index 100% rename from pandapipes/properties/oxygen/heat_capacity.txt rename to src/pandapipes/properties/oxygen/heat_capacity.txt diff --git a/pandapipes/properties/oxygen/molar_mass.txt b/src/pandapipes/properties/oxygen/molar_mass.txt similarity index 100% rename from pandapipes/properties/oxygen/molar_mass.txt rename to src/pandapipes/properties/oxygen/molar_mass.txt diff --git a/pandapipes/properties/oxygen/viscosity.txt b/src/pandapipes/properties/oxygen/viscosity.txt similarity index 100% rename from pandapipes/properties/oxygen/viscosity.txt rename to src/pandapipes/properties/oxygen/viscosity.txt diff --git a/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py similarity index 100% rename from pandapipes/properties/properties_toolbox.py rename to src/pandapipes/properties/properties_toolbox.py diff --git a/pandapipes/properties/water/compressibility.txt b/src/pandapipes/properties/water/compressibility.txt similarity index 100% rename from pandapipes/properties/water/compressibility.txt rename to src/pandapipes/properties/water/compressibility.txt diff --git a/pandapipes/properties/water/density.txt b/src/pandapipes/properties/water/density.txt similarity index 100% rename from pandapipes/properties/water/density.txt rename to src/pandapipes/properties/water/density.txt diff --git a/pandapipes/properties/water/der_compressibility.txt b/src/pandapipes/properties/water/der_compressibility.txt similarity index 100% rename from pandapipes/properties/water/der_compressibility.txt rename to src/pandapipes/properties/water/der_compressibility.txt diff --git a/pandapipes/properties/water/heat_capacity.txt b/src/pandapipes/properties/water/heat_capacity.txt similarity index 100% rename from pandapipes/properties/water/heat_capacity.txt rename to src/pandapipes/properties/water/heat_capacity.txt diff --git a/pandapipes/properties/water/molar_mass.txt b/src/pandapipes/properties/water/molar_mass.txt similarity index 100% rename from pandapipes/properties/water/molar_mass.txt rename to src/pandapipes/properties/water/molar_mass.txt diff --git a/pandapipes/properties/water/viscosity.txt b/src/pandapipes/properties/water/viscosity.txt similarity index 100% rename from pandapipes/properties/water/viscosity.txt rename to src/pandapipes/properties/water/viscosity.txt diff --git a/pandapipes/std_types/__init__.py b/src/pandapipes/std_types/__init__.py similarity index 100% rename from pandapipes/std_types/__init__.py rename to src/pandapipes/std_types/__init__.py diff --git a/pandapipes/std_types/library/Pipe.csv b/src/pandapipes/std_types/library/Pipe.csv similarity index 100% rename from pandapipes/std_types/library/Pipe.csv rename to src/pandapipes/std_types/library/Pipe.csv diff --git a/pandapipes/std_types/library/Pump/P1.csv b/src/pandapipes/std_types/library/Pump/P1.csv similarity index 100% rename from pandapipes/std_types/library/Pump/P1.csv rename to src/pandapipes/std_types/library/Pump/P1.csv diff --git a/pandapipes/std_types/library/Pump/P2.csv b/src/pandapipes/std_types/library/Pump/P2.csv similarity index 100% rename from pandapipes/std_types/library/Pump/P2.csv rename to src/pandapipes/std_types/library/Pump/P2.csv diff --git a/pandapipes/std_types/library/Pump/P3.csv b/src/pandapipes/std_types/library/Pump/P3.csv similarity index 100% rename from pandapipes/std_types/library/Pump/P3.csv rename to src/pandapipes/std_types/library/Pump/P3.csv diff --git a/pandapipes/std_types/std_type_class.py b/src/pandapipes/std_types/std_type_class.py similarity index 100% rename from pandapipes/std_types/std_type_class.py rename to src/pandapipes/std_types/std_type_class.py diff --git a/pandapipes/std_types/std_types.py b/src/pandapipes/std_types/std_types.py similarity index 100% rename from pandapipes/std_types/std_types.py rename to src/pandapipes/std_types/std_types.py diff --git a/pandapipes/test/__init__.py b/src/pandapipes/test/__init__.py similarity index 100% rename from pandapipes/test/__init__.py rename to src/pandapipes/test/__init__.py diff --git a/pandapipes/test/api/__init__.py b/src/pandapipes/test/api/__init__.py similarity index 100% rename from pandapipes/test/api/__init__.py rename to src/pandapipes/test/api/__init__.py diff --git a/pandapipes/test/api/old_versions/example_0.1.0.json b/src/pandapipes/test/api/old_versions/example_0.1.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.1.0.json rename to src/pandapipes/test/api/old_versions/example_0.1.0.json diff --git a/pandapipes/test/api/old_versions/example_0.1.1.json b/src/pandapipes/test/api/old_versions/example_0.1.1.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.1.1.json rename to src/pandapipes/test/api/old_versions/example_0.1.1.json diff --git a/pandapipes/test/api/old_versions/example_0.1.2.json b/src/pandapipes/test/api/old_versions/example_0.1.2.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.1.2.json rename to src/pandapipes/test/api/old_versions/example_0.1.2.json diff --git a/pandapipes/test/api/old_versions/example_0.2.0.json b/src/pandapipes/test/api/old_versions/example_0.2.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.2.0.json rename to src/pandapipes/test/api/old_versions/example_0.2.0.json diff --git a/pandapipes/test/api/old_versions/example_0.4.0.json b/src/pandapipes/test/api/old_versions/example_0.4.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.4.0.json rename to src/pandapipes/test/api/old_versions/example_0.4.0.json diff --git a/pandapipes/test/api/old_versions/example_0.5.0.json b/src/pandapipes/test/api/old_versions/example_0.5.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.5.0.json rename to src/pandapipes/test/api/old_versions/example_0.5.0.json diff --git a/pandapipes/test/api/old_versions/example_0.6.0.json b/src/pandapipes/test/api/old_versions/example_0.6.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.6.0.json rename to src/pandapipes/test/api/old_versions/example_0.6.0.json diff --git a/pandapipes/test/api/old_versions/example_0.7.0.json b/src/pandapipes/test/api/old_versions/example_0.7.0.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.7.0.json rename to src/pandapipes/test/api/old_versions/example_0.7.0.json diff --git a/pandapipes/test/api/old_versions/example_0.8.0_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.0_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.0_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.0_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.0_water.json b/src/pandapipes/test/api/old_versions/example_0.8.0_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.0_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.0_water.json diff --git a/pandapipes/test/api/old_versions/example_0.8.1_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.1_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.1_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.1_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.1_water.json b/src/pandapipes/test/api/old_versions/example_0.8.1_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.1_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.1_water.json diff --git a/pandapipes/test/api/old_versions/example_0.8.2_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.2_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.2_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.2_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.2_water.json b/src/pandapipes/test/api/old_versions/example_0.8.2_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.2_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.2_water.json diff --git a/pandapipes/test/api/old_versions/example_0.8.3_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.3_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.3_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.3_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.3_water.json b/src/pandapipes/test/api/old_versions/example_0.8.3_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.3_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.3_water.json diff --git a/pandapipes/test/api/old_versions/example_0.8.4_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.4_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.4_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.4_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.4_water.json b/src/pandapipes/test/api/old_versions/example_0.8.4_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.4_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.4_water.json diff --git a/pandapipes/test/api/old_versions/example_0.8.5_gas.json b/src/pandapipes/test/api/old_versions/example_0.8.5_gas.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.5_gas.json rename to src/pandapipes/test/api/old_versions/example_0.8.5_gas.json diff --git a/pandapipes/test/api/old_versions/example_0.8.5_water.json b/src/pandapipes/test/api/old_versions/example_0.8.5_water.json similarity index 100% rename from pandapipes/test/api/old_versions/example_0.8.5_water.json rename to src/pandapipes/test/api/old_versions/example_0.8.5_water.json diff --git a/pandapipes/test/api/release_cycle/release_control_test_network.py b/src/pandapipes/test/api/release_cycle/release_control_test_network.py similarity index 100% rename from pandapipes/test/api/release_cycle/release_control_test_network.py rename to src/pandapipes/test/api/release_cycle/release_control_test_network.py diff --git a/pandapipes/test/api/release_cycle/release_control_test_sink_profiles.csv b/src/pandapipes/test/api/release_cycle/release_control_test_sink_profiles.csv similarity index 100% rename from pandapipes/test/api/release_cycle/release_control_test_sink_profiles.csv rename to src/pandapipes/test/api/release_cycle/release_control_test_sink_profiles.csv diff --git a/pandapipes/test/api/release_cycle/release_control_test_source_profiles.csv b/src/pandapipes/test/api/release_cycle/release_control_test_source_profiles.csv similarity index 100% rename from pandapipes/test/api/release_cycle/release_control_test_source_profiles.csv rename to src/pandapipes/test/api/release_cycle/release_control_test_source_profiles.csv diff --git a/pandapipes/test/api/test_aux_function.py b/src/pandapipes/test/api/test_aux_function.py similarity index 100% rename from pandapipes/test/api/test_aux_function.py rename to src/pandapipes/test/api/test_aux_function.py diff --git a/pandapipes/test/api/test_components/__init__.py b/src/pandapipes/test/api/test_components/__init__.py similarity index 100% rename from pandapipes/test/api/test_components/__init__.py rename to src/pandapipes/test/api/test_components/__init__.py diff --git a/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py similarity index 100% rename from pandapipes/test/api/test_components/test_circ_pump_mass.py rename to src/pandapipes/test/api/test_components/test_circ_pump_mass.py diff --git a/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py similarity index 100% rename from pandapipes/test/api/test_components/test_circ_pump_pressure.py rename to src/pandapipes/test/api/test_components/test_circ_pump_pressure.py diff --git a/pandapipes/test/api/test_components/test_compressor.py b/src/pandapipes/test/api/test_components/test_compressor.py similarity index 100% rename from pandapipes/test/api/test_components/test_compressor.py rename to src/pandapipes/test/api/test_components/test_compressor.py diff --git a/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py similarity index 100% rename from pandapipes/test/api/test_components/test_ext_grid.py rename to src/pandapipes/test/api/test_components/test_ext_grid.py diff --git a/pandapipes/test/api/test_components/test_flow_control.py b/src/pandapipes/test/api/test_components/test_flow_control.py similarity index 100% rename from pandapipes/test/api/test_components/test_flow_control.py rename to src/pandapipes/test/api/test_components/test_flow_control.py diff --git a/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py similarity index 100% rename from pandapipes/test/api/test_components/test_heat_exchanger.py rename to src/pandapipes/test/api/test_components/test_heat_exchanger.py diff --git a/pandapipes/test/api/test_components/test_mass_storage.py b/src/pandapipes/test/api/test_components/test_mass_storage.py similarity index 100% rename from pandapipes/test/api/test_components/test_mass_storage.py rename to src/pandapipes/test/api/test_components/test_mass_storage.py diff --git a/pandapipes/test/api/test_components/test_pipe_results.py b/src/pandapipes/test/api/test_components/test_pipe_results.py similarity index 100% rename from pandapipes/test/api/test_components/test_pipe_results.py rename to src/pandapipes/test/api/test_components/test_pipe_results.py diff --git a/pandapipes/test/api/test_components/test_pressure_control.py b/src/pandapipes/test/api/test_components/test_pressure_control.py similarity index 100% rename from pandapipes/test/api/test_components/test_pressure_control.py rename to src/pandapipes/test/api/test_components/test_pressure_control.py diff --git a/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py similarity index 100% rename from pandapipes/test/api/test_components/test_pump.py rename to src/pandapipes/test/api/test_components/test_pump.py diff --git a/pandapipes/test/api/test_components/test_valve.py b/src/pandapipes/test/api/test_components/test_valve.py similarity index 100% rename from pandapipes/test/api/test_components/test_valve.py rename to src/pandapipes/test/api/test_components/test_valve.py diff --git a/pandapipes/test/api/test_convert_format.py b/src/pandapipes/test/api/test_convert_format.py similarity index 100% rename from pandapipes/test/api/test_convert_format.py rename to src/pandapipes/test/api/test_convert_format.py diff --git a/pandapipes/test/api/test_create.py b/src/pandapipes/test/api/test_create.py similarity index 100% rename from pandapipes/test/api/test_create.py rename to src/pandapipes/test/api/test_create.py diff --git a/pandapipes/test/api/test_network_tables.py b/src/pandapipes/test/api/test_network_tables.py similarity index 100% rename from pandapipes/test/api/test_network_tables.py rename to src/pandapipes/test/api/test_network_tables.py diff --git a/pandapipes/test/api/test_special_networks.py b/src/pandapipes/test/api/test_special_networks.py similarity index 100% rename from pandapipes/test/api/test_special_networks.py rename to src/pandapipes/test/api/test_special_networks.py diff --git a/pandapipes/test/api/test_std_types.py b/src/pandapipes/test/api/test_std_types.py similarity index 100% rename from pandapipes/test/api/test_std_types.py rename to src/pandapipes/test/api/test_std_types.py diff --git a/pandapipes/test/api/test_time_series.py b/src/pandapipes/test/api/test_time_series.py similarity index 100% rename from pandapipes/test/api/test_time_series.py rename to src/pandapipes/test/api/test_time_series.py diff --git a/pandapipes/test/converter/__init__.py b/src/pandapipes/test/converter/__init__.py similarity index 100% rename from pandapipes/test/converter/__init__.py rename to src/pandapipes/test/converter/__init__.py diff --git a/pandapipes/test/converter/converter_test_files/Exampelonia_mini.csv b/src/pandapipes/test/converter/converter_test_files/Exampelonia_mini.csv similarity index 100% rename from pandapipes/test/converter/converter_test_files/Exampelonia_mini.csv rename to src/pandapipes/test/converter/converter_test_files/Exampelonia_mini.csv diff --git a/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_2valvepipe.csv b/src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_2valvepipe.csv similarity index 100% rename from pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_2valvepipe.csv rename to src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_2valvepipe.csv diff --git a/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_closed.csv b/src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_closed.csv similarity index 100% rename from pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_closed.csv rename to src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_closed.csv diff --git a/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_open.csv b/src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_open.csv similarity index 100% rename from pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_open.csv rename to src/pandapipes/test/converter/converter_test_files/Exampelonia_mini_with_valve_2sliders_open.csv diff --git a/pandapipes/test/converter/test_stanet_converter.py b/src/pandapipes/test/converter/test_stanet_converter.py similarity index 100% rename from pandapipes/test/converter/test_stanet_converter.py rename to src/pandapipes/test/converter/test_stanet_converter.py diff --git a/pandapipes/test/io/__init__.py b/src/pandapipes/test/io/__init__.py similarity index 100% rename from pandapipes/test/io/__init__.py rename to src/pandapipes/test/io/__init__.py diff --git a/pandapipes/test/io/test_file_io.py b/src/pandapipes/test/io/test_file_io.py similarity index 100% rename from pandapipes/test/io/test_file_io.py rename to src/pandapipes/test/io/test_file_io.py diff --git a/pandapipes/test/multinet/__init__.py b/src/pandapipes/test/multinet/__init__.py similarity index 100% rename from pandapipes/test/multinet/__init__.py rename to src/pandapipes/test/multinet/__init__.py diff --git a/pandapipes/test/multinet/test_control_multinet.py b/src/pandapipes/test/multinet/test_control_multinet.py similarity index 100% rename from pandapipes/test/multinet/test_control_multinet.py rename to src/pandapipes/test/multinet/test_control_multinet.py diff --git a/pandapipes/test/multinet/test_time_series_multinet.py b/src/pandapipes/test/multinet/test_time_series_multinet.py similarity index 100% rename from pandapipes/test/multinet/test_time_series_multinet.py rename to src/pandapipes/test/multinet/test_time_series_multinet.py diff --git a/pandapipes/test/networks/__init__.py b/src/pandapipes/test/networks/__init__.py similarity index 100% rename from pandapipes/test/networks/__init__.py rename to src/pandapipes/test/networks/__init__.py diff --git a/pandapipes/test/networks/test_networks.py b/src/pandapipes/test/networks/test_networks.py similarity index 100% rename from pandapipes/test/networks/test_networks.py rename to src/pandapipes/test/networks/test_networks.py diff --git a/pandapipes/test/openmodelica_comparison/__init__.py b/src/pandapipes/test/openmodelica_comparison/__init__.py similarity index 100% rename from pandapipes/test/openmodelica_comparison/__init__.py rename to src/pandapipes/test/openmodelica_comparison/__init__.py diff --git a/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py similarity index 100% rename from pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py rename to src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py diff --git a/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py similarity index 100% rename from pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py rename to src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py diff --git a/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py similarity index 100% rename from pandapipes/test/openmodelica_comparison/test_water_openmodelica.py rename to src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py diff --git a/pandapipes/test/pipeflow_internals/__init__.py b/src/pandapipes/test/pipeflow_internals/__init__.py similarity index 100% rename from pandapipes/test/pipeflow_internals/__init__.py rename to src/pandapipes/test/pipeflow_internals/__init__.py diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv b/src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv rename to src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/ext_grid_p.csv b/src/pandapipes/test/pipeflow_internals/data/ext_grid_p.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/ext_grid_p.csv rename to src/pandapipes/test/pipeflow_internals/data/ext_grid_p.csv diff --git a/pandapipes/test/pipeflow_internals/data/gas_sections_an.csv b/src/pandapipes/test/pipeflow_internals/data/gas_sections_an.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/gas_sections_an.csv rename to src/pandapipes/test/pipeflow_internals/data/gas_sections_an.csv diff --git a/pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv b/src/pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv rename to src/pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv diff --git a/pandapipes/test/pipeflow_internals/data/hydraulics.csv b/src/pandapipes/test/pipeflow_internals/data/hydraulics.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/hydraulics.csv rename to src/pandapipes/test/pipeflow_internals/data/hydraulics.csv diff --git a/pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv b/src/pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv rename to src/pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv b/src/pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv rename to src/pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv b/src/pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv rename to src/pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv b/src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_pressure_control.csv rename to src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_pump.csv b/src/pandapipes/test/pipeflow_internals/data/test_pump.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_pump.csv rename to src/pandapipes/test/pipeflow_internals/data/test_pump.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv rename to src/pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv diff --git a/pandapipes/test/pipeflow_internals/data/test_valve.csv b/src/pandapipes/test/pipeflow_internals/data/test_valve.csv similarity index 100% rename from pandapipes/test/pipeflow_internals/data/test_valve.csv rename to src/pandapipes/test/pipeflow_internals/data/test_valve.csv diff --git a/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_inservice.py rename to src/pandapipes/test/pipeflow_internals/test_inservice.py diff --git a/pandapipes/test/pipeflow_internals/test_non_convergence.py b/src/pandapipes/test/pipeflow_internals/test_non_convergence.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_non_convergence.py rename to src/pandapipes/test/pipeflow_internals/test_non_convergence.py diff --git a/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_options.py rename to src/pandapipes/test/pipeflow_internals/test_options.py diff --git a/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py rename to src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py diff --git a/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_pipeflow_modes.py rename to src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py diff --git a/pandapipes/test/pipeflow_internals/test_time_series.py b/src/pandapipes/test/pipeflow_internals/test_time_series.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_time_series.py rename to src/pandapipes/test/pipeflow_internals/test_time_series.py diff --git a/pandapipes/test/pipeflow_internals/test_update_matrix.py b/src/pandapipes/test/pipeflow_internals/test_update_matrix.py similarity index 100% rename from pandapipes/test/pipeflow_internals/test_update_matrix.py rename to src/pandapipes/test/pipeflow_internals/test_update_matrix.py diff --git a/pandapipes/test/plotting/__init__.py b/src/pandapipes/test/plotting/__init__.py similarity index 100% rename from pandapipes/test/plotting/__init__.py rename to src/pandapipes/test/plotting/__init__.py diff --git a/pandapipes/test/plotting/test_collections.py b/src/pandapipes/test/plotting/test_collections.py similarity index 100% rename from pandapipes/test/plotting/test_collections.py rename to src/pandapipes/test/plotting/test_collections.py diff --git a/pandapipes/test/plotting/test_generic_coordinates.py b/src/pandapipes/test/plotting/test_generic_coordinates.py similarity index 100% rename from pandapipes/test/plotting/test_generic_coordinates.py rename to src/pandapipes/test/plotting/test_generic_coordinates.py diff --git a/pandapipes/test/plotting/test_pipeflow_results.py b/src/pandapipes/test/plotting/test_pipeflow_results.py similarity index 100% rename from pandapipes/test/plotting/test_pipeflow_results.py rename to src/pandapipes/test/plotting/test_pipeflow_results.py diff --git a/pandapipes/test/plotting/test_simple_collections.py b/src/pandapipes/test/plotting/test_simple_collections.py similarity index 100% rename from pandapipes/test/plotting/test_simple_collections.py rename to src/pandapipes/test/plotting/test_simple_collections.py diff --git a/pandapipes/test/properties/__init__.py b/src/pandapipes/test/properties/__init__.py similarity index 100% rename from pandapipes/test/properties/__init__.py rename to src/pandapipes/test/properties/__init__.py diff --git a/pandapipes/test/properties/test_fluid_specials.py b/src/pandapipes/test/properties/test_fluid_specials.py similarity index 100% rename from pandapipes/test/properties/test_fluid_specials.py rename to src/pandapipes/test/properties/test_fluid_specials.py diff --git a/pandapipes/test/properties/test_properties_toolbox.py b/src/pandapipes/test/properties/test_properties_toolbox.py similarity index 100% rename from pandapipes/test/properties/test_properties_toolbox.py rename to src/pandapipes/test/properties/test_properties_toolbox.py diff --git a/pandapipes/test/pytest.ini b/src/pandapipes/test/pytest.ini similarity index 100% rename from pandapipes/test/pytest.ini rename to src/pandapipes/test/pytest.ini diff --git a/pandapipes/test/run_tests.py b/src/pandapipes/test/run_tests.py similarity index 100% rename from pandapipes/test/run_tests.py rename to src/pandapipes/test/run_tests.py diff --git a/pandapipes/test/stanet_comparison/__init__.py b/src/pandapipes/test/stanet_comparison/__init__.py similarity index 100% rename from pandapipes/test/stanet_comparison/__init__.py rename to src/pandapipes/test/stanet_comparison/__init__.py diff --git a/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py similarity index 100% rename from pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py rename to src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py diff --git a/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py similarity index 100% rename from pandapipes/test/stanet_comparison/test_gas_stanet.py rename to src/pandapipes/test/stanet_comparison/test_gas_stanet.py diff --git a/pandapipes/test/stanet_comparison/test_water_stanet.py b/src/pandapipes/test/stanet_comparison/test_water_stanet.py similarity index 100% rename from pandapipes/test/stanet_comparison/test_water_stanet.py rename to src/pandapipes/test/stanet_comparison/test_water_stanet.py diff --git a/pandapipes/test/test_imports.py b/src/pandapipes/test/test_imports.py similarity index 100% rename from pandapipes/test/test_imports.py rename to src/pandapipes/test/test_imports.py diff --git a/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py similarity index 100% rename from pandapipes/test/test_toolbox.py rename to src/pandapipes/test/test_toolbox.py diff --git a/pandapipes/test/topology/__init__.py b/src/pandapipes/test/topology/__init__.py similarity index 100% rename from pandapipes/test/topology/__init__.py rename to src/pandapipes/test/topology/__init__.py diff --git a/pandapipes/test/topology/test_graph_searches.py b/src/pandapipes/test/topology/test_graph_searches.py similarity index 100% rename from pandapipes/test/topology/test_graph_searches.py rename to src/pandapipes/test/topology/test_graph_searches.py diff --git a/pandapipes/test/topology/test_nxgraph.py b/src/pandapipes/test/topology/test_nxgraph.py similarity index 100% rename from pandapipes/test/topology/test_nxgraph.py rename to src/pandapipes/test/topology/test_nxgraph.py diff --git a/pandapipes/timeseries/__init__.py b/src/pandapipes/timeseries/__init__.py similarity index 100% rename from pandapipes/timeseries/__init__.py rename to src/pandapipes/timeseries/__init__.py diff --git a/pandapipes/timeseries/run_time_series.py b/src/pandapipes/timeseries/run_time_series.py similarity index 100% rename from pandapipes/timeseries/run_time_series.py rename to src/pandapipes/timeseries/run_time_series.py diff --git a/pandapipes/toolbox.py b/src/pandapipes/toolbox.py similarity index 100% rename from pandapipes/toolbox.py rename to src/pandapipes/toolbox.py diff --git a/pandapipes/topology/__init__.py b/src/pandapipes/topology/__init__.py similarity index 100% rename from pandapipes/topology/__init__.py rename to src/pandapipes/topology/__init__.py diff --git a/pandapipes/topology/create_graph.py b/src/pandapipes/topology/create_graph.py similarity index 100% rename from pandapipes/topology/create_graph.py rename to src/pandapipes/topology/create_graph.py diff --git a/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py similarity index 100% rename from pandapipes/topology/graph_searches.py rename to src/pandapipes/topology/graph_searches.py From 893452481d923f02cd7044de1f9a95698228d3ab Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 15:01:19 +0100 Subject: [PATCH 044/237] removing pytest.ini, restructuring setup.py slighly and adapt MANIFEST.in to just consider all files in src --- MANIFEST.in | 8 ++------ pytest.ini | 3 --- setup.py | 7 ++++--- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 pytest.ini diff --git a/MANIFEST.in b/MANIFEST.in index 4c6085d5a..9a3b2f780 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,3 @@ -include LICENSE AUTHORS README.rst CHANGELOG.rst .github/**/*.yml -global-include *.json -global-include *.csv -global-include *.txt +graft src -prune doc* -prune tutorials* +include LICENSE AUTHORS README.rst CHANGELOG.rst .github/**/*.yml diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index a01d26adf..000000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -python_paths = . .. -site_dirs = . .. \ No newline at end of file diff --git a/setup.py b/setup.py index 5ad029dc3..46526a0b4 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,10 @@ # 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 re + from setuptools import find_namespace_packages from setuptools import setup -import re with open('README.rst', 'rb') as f: install = f.read().decode('utf-8') @@ -40,7 +41,7 @@ 'jolando.kisse@uni-kassel.de', description='A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids', long_description=long_description, - long_description_content_type='text/x-rst', + long_description_content_type='text/x-rst', url='http://www.pandapipes.org', license='BSD', install_requires=["pandapower>=2.11.1", "matplotlib", "shapely"], @@ -50,7 +51,7 @@ "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, packages=find_namespace_packages(where='src'), - package_dir={"":"src"}, + package_dir={"": "src"}, include_package_data=True, classifiers=classifiers ) From a70f32cd9d93926a944e9333d07e5a35c03d7db3 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 15:36:48 +0100 Subject: [PATCH 045/237] change pandapipes reference in tutorial test --- tutorials/standard_libraries.ipynb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tutorials/standard_libraries.ipynb b/tutorials/standard_libraries.ipynb index bad801240..2f4d2ef11 100644 --- a/tutorials/standard_libraries.ipynb +++ b/tutorials/standard_libraries.ipynb @@ -36,8 +36,13 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", + "\n", "from pandapipes.std_types.std_type_class import get_data\n", - "print(get_data(r'../pandapipes/std_types/library/Pipe.csv', 'pipe'))" + "from pandapipes import pp_dir\n", + "\n", + "path = os.path.join(pp_dir, 'std_types/library/Pipe.csv')\n", + "print(get_data(path, 'pipe'))" ] }, { @@ -124,7 +129,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(get_data(r'../pandapipes/std_types/library/Pump/P1.csv', 'pump'))" + "path = os.path.join(pp_dir, 'std_types/library/Pump/P1.csv')\n", + "print(get_data(path, 'pump'))" ] }, { From b84a6b70f414c2b9f9dcdb425d4b33e67353a152 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Wed, 13 Dec 2023 16:14:22 +0100 Subject: [PATCH 046/237] remove pytest.ini from tutorials --- tutorials/pytest.ini | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 tutorials/pytest.ini diff --git a/tutorials/pytest.ini b/tutorials/pytest.ini deleted file mode 100644 index a01d26adf..000000000 --- a/tutorials/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -python_paths = . .. -site_dirs = . .. \ No newline at end of file From f1d9ba74413bd7f912f5f8446c00253f25cdf80d Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Thu, 14 Dec 2023 16:05:17 +0100 Subject: [PATCH 047/237] switch pump junctions in DHN tutorial; closes #580 --- tutorials/circular_flow_in_a_district_heating_grid.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/circular_flow_in_a_district_heating_grid.ipynb b/tutorials/circular_flow_in_a_district_heating_grid.ipynb index 5fe99d839..a06e23669 100644 --- a/tutorials/circular_flow_in_a_district_heating_grid.ipynb +++ b/tutorials/circular_flow_in_a_district_heating_grid.ipynb @@ -71,7 +71,7 @@ "metadata": {}, "outputs": [], "source": [ - "pp.create_circ_pump_const_mass_flow(net, return_junction=j0, flow_junction=j3, p_flow_bar=5,\n", + "pp.create_circ_pump_const_mass_flow(net, return_junction=j3, flow_junction=j0, p_flow_bar=5,\n", " mdot_flow_kg_per_s=20, t_flow_k=273.15+35)" ] }, From 6fec1cf1545929ec74a2d1a15b597b3575f5827c Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 15 Dec 2023 20:53:08 +0100 Subject: [PATCH 048/237] converged is explicit. Only under net defined. --- pandapipes/pf/pipeflow_setup.py | 2 +- pandapipes/pipeflow.py | 38 ++++++++------------ pandapipes/test/api/test_special_networks.py | 2 +- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/pandapipes/pf/pipeflow_setup.py b/pandapipes/pf/pipeflow_setup.py index 713f05be8..795fbabda 100644 --- a/pandapipes/pf/pipeflow_setup.py +++ b/pandapipes/pf/pipeflow_setup.py @@ -31,7 +31,7 @@ logger = logging.getLogger(__name__) -default_options = {"friction_model": "nikuradse", "converged": False, "tol_p": 1e-4, "tol_v": 1e-4, +default_options = {"friction_model": "nikuradse", "tol_p": 1e-4, "tol_v": 1e-4, "tol_T": 1e-3, "tol_res": 1e-3, "iter": 10, "error_flag": False, "alpha": 1, "nonlinear_method": "constant", "mode": "hydraulics", "ambient_temperature": 293, "check_connectivity": True, diff --git a/pandapipes/pipeflow.py b/pandapipes/pipeflow.py index aa9f49947..6f1184929 100644 --- a/pandapipes/pipeflow.py +++ b/pandapipes/pipeflow.py @@ -65,7 +65,7 @@ def pipeflow(net, sol_vec=None, **kwargs): init_options(net, local_params) # init result tables - net["converged"] = False + net.converged = False init_all_result_tables(net) create_lookups(net) @@ -90,8 +90,8 @@ def pipeflow(net, sol_vec=None, **kwargs): if calculate_hydraulics: reduce_pit(net, node_pit, branch_pit, mode="hydraulics") - converged, _ = hydraulics(net) - if not converged: + hydraulics(net) + if not net.converged: raise PipeflowNotConverged("The hydraulic calculation did not converge to a solution.") extract_results_active_pit(net, mode="hydraulics") @@ -99,8 +99,8 @@ def pipeflow(net, sol_vec=None, **kwargs): node_pit, branch_pit = net["_pit"]["node"], net["_pit"]["branch"] identify_active_nodes_branches(net, branch_pit, node_pit, False) reduce_pit(net, node_pit, branch_pit, mode="heat_transfer") - converged, _ = heat_transfer(net) - if not converged: + heat_transfer(net) + if not net.converged: raise PipeflowNotConverged("The heat transfer calculation did not converge to a " "solution.") extract_results_active_pit(net, mode="heat_transfer") @@ -125,7 +125,7 @@ def hydraulics(net): error_v, error_p, residual_norm = [], [], None # This loop is left as soon as the solver converged - while not get_net_option(net, "converged") and niter <= max_iter: + while not net.converged and niter <= max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place @@ -145,17 +145,13 @@ def hydraulics(net): write_internal_results(net, iterations=niter, error_p=error_p[niter - 1], error_v=error_v[niter - 1], residual_norm=residual_norm) - converged = get_net_option(net, "converged") - net['converged'] = converged - if converged: + if net.converged: set_user_pf_options(net, hyd_flag=True) - log_final_results(net, converged, niter, residual_norm) + log_final_results(net, niter, residual_norm) if not get_net_option(net, "reuse_internal_data"): net.pop("_internal_data", None) - return converged, niter - def heat_transfer(net): max_iter, nonlinear_method, tol_t, tol_res = get_net_options( @@ -170,11 +166,11 @@ def heat_transfer(net): error_t, error_t_out, residual_norm = [], [], None - set_net_option(net, "converged", False) + net.converged = False niter = 0 # This loop is left as soon as the solver converged - while not get_net_option(net, "converged") and niter <= max_iter: + while not net.converged and niter <= max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place @@ -198,11 +194,7 @@ def heat_transfer(net): write_internal_results(net, iterations_T=niter, error_T=error_t[niter - 1], residual_norm_T=residual_norm) - converged = get_net_option(net, "converged") - net['converged'] = converged - log_final_results(net, converged, niter, residual_norm, hyraulic_mode=False) - - return converged, niter + log_final_results(net, niter, residual_norm, hyraulic_mode=False) def solve_hydraulics(net): @@ -334,9 +326,9 @@ def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_me # Setting convergence flag if error_2[niter] <= tol_2 and error_1[niter] <= tol_1 and residual_norm < tol_res: if nonlinear_method != "automatic": - set_net_option(net, "converged", True) + net.converged = True elif get_net_option(net, "alpha") == 1: - set_net_option(net, "converged", True) + net.converged = True if hydraulic_mode: logger.debug("errorv: %s" % error_1[niter]) @@ -347,7 +339,7 @@ def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_me logger.debug("alpha: %s" % get_net_option(net, "alpha")) -def log_final_results(net, converged, niter, residual_norm, hyraulic_mode=True): +def log_final_results(net, niter, residual_norm, hyraulic_mode=True): if hyraulic_mode: solver = "hydraulics" outputs = ["tol_p", "tol_v"] @@ -355,7 +347,7 @@ def log_final_results(net, converged, niter, residual_norm, hyraulic_mode=True): solver = "heat transfer" outputs = ["tol_T"] logger.debug("--------------------------------------------------------------------------------") - if not converged: + if not net.converged: logger.debug("Maximum number of iterations reached but %s solver did not converge." % solver) logger.debug("Norm of residual: %s" % residual_norm) diff --git a/pandapipes/test/api/test_special_networks.py b/pandapipes/test/api/test_special_networks.py index 0015844e4..1b09cd661 100644 --- a/pandapipes/test/api/test_special_networks.py +++ b/pandapipes/test/api/test_special_networks.py @@ -117,7 +117,7 @@ def test_wild_indexing(create_net_changed_indices): net = copy.deepcopy(create_net_changed_indices) pandapipes.pipeflow(net) - assert net["converged"] + assert net.converged if __name__ == "__main__": From 0c931724bff99fa5e137093030c926ee2272d0e4 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 19 Dec 2023 11:52:46 +0100 Subject: [PATCH 049/237] remove logger set level --- src/pandapipes/multinet/create_multinet.py | 1 - src/pandapipes/timeseries/run_time_series.py | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pandapipes/multinet/create_multinet.py b/src/pandapipes/multinet/create_multinet.py index 4a5352a5c..64a31df44 100644 --- a/src/pandapipes/multinet/create_multinet.py +++ b/src/pandapipes/multinet/create_multinet.py @@ -12,7 +12,6 @@ import logging logger = logging.getLogger(__name__) -logger.setLevel(level=logging.WARNING) def create_empty_multinet(name=""): diff --git a/src/pandapipes/timeseries/run_time_series.py b/src/pandapipes/timeseries/run_time_series.py index beab805e1..60ca01cdc 100644 --- a/src/pandapipes/timeseries/run_time_series.py +++ b/src/pandapipes/timeseries/run_time_series.py @@ -4,12 +4,11 @@ import tempfile -from pandapower.control import NetCalculationNotConverged - from pandapipes.pipeflow import PipeflowNotConverged, pipeflow +from pandapower.control import NetCalculationNotConverged from pandapower.control.util.diagnostic import control_diagnostic from pandapower.timeseries.output_writer import OutputWriter -from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup,\ +from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup, \ run_loop try: @@ -18,7 +17,6 @@ import logging logger = logging.getLogger(__name__) -logger.setLevel(level=logging.WARNING) def init_default_outputwriter(net, time_steps, **kwargs): From 2d33bc975379a3e4bcdad7ec1e90e643257183d1 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 19 Dec 2023 13:11:33 +0100 Subject: [PATCH 050/237] - move Pipeflow Exception into pipeflow setup - improve pipeflow oos test - remove logger setups as they are not working --- pandapipes/pf/pipeflow_setup.py | 19 ++++++++++-- pandapipes/pipeflow.py | 19 +++--------- .../test/pipeflow_internals/test_inservice.py | 30 ++++++++++++------- pandapipes/timeseries/run_time_series.py | 7 ++--- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/pandapipes/pf/pipeflow_setup.py b/pandapipes/pf/pipeflow_setup.py index 4034bbb39..1b314a462 100644 --- a/pandapipes/pf/pipeflow_setup.py +++ b/pandapipes/pf/pipeflow_setup.py @@ -6,6 +6,7 @@ import inspect import numpy as np +from pandapower.auxiliary import ppException from scipy.sparse import coo_matrix, csgraph from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ @@ -22,6 +23,7 @@ numba_installed = True except ImportError: from pandapower.pf.no_numba import jit + numba_installed = False try: @@ -496,9 +498,13 @@ def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): # here, any value between 0 and 1 should work, excluding 0 and 1) nodes_connected[fn_tn] = nodes_connected[fn_tn] & (flow > 0.1) mode = "hydraulics" if hydraulic else "heat_transfer" + if np.all(~nodes_connected): + mode = 'hydraulic' if hydraulic else 'heat transfer' + raise PipeflowNotConverged(" All nodes are set out of service. Probably they are not supplied." + " Therefore, the %s pipeflow did not converge. " + " Have you forgotten to define an external grid?" % mode) net["_lookups"]["node_active_" + mode] = nodes_connected net["_lookups"]["branch_active_" + mode] = branches_connected - return node_pit[nodes_connected], branch_pit[branches_connected] def branches_connected_flow(branch_pit): @@ -552,7 +558,7 @@ def check_connectivity(net, branch_pit, node_pit, mode="hydraulics"): else: active_branch_lookup = branches_connected_flow(branch_pit) \ & get_lookup(net, "branch", "active_hydraulics") - active_node_lookup = node_pit[:, ACTIVE_ND].astype(np.bool_)\ + active_node_lookup = node_pit[:, ACTIVE_ND].astype(np.bool_) \ & get_lookup(net, "node", "active_hydraulics") slacks = np.where((node_pit[:, NODE_TYPE_T] == T) & active_node_lookup)[0] @@ -635,7 +641,7 @@ def get_table_index_list(net, pit_array, pit_indices, pit_type="node"): tables = np.unique(int_pit[:, TABLE_IDX_ND]) table_lookup = get_lookup(net, pit_type, "table") return [(get_table_name(table_lookup, tbl), list(int_pit[int_pit[:, TABLE_IDX_ND] == tbl, - ELEMENT_IDX_ND].astype(np.int32))) + ELEMENT_IDX_ND].astype(np.int32))) for tbl in tables] @@ -710,3 +716,10 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): from_to_active_lookup[table] = (count, count + len_new) count += len_new net["_lookups"]["%s_from_to_active_%s" % (el, mode)] = from_to_active_lookup + + +class PipeflowNotConverged(ppException): + """ + Exception being raised in case pipeflow did not converge. + """ + pass diff --git a/pandapipes/pipeflow.py b/pandapipes/pipeflow.py index 886ed571e..4dab2f9f1 100644 --- a/pandapipes/pipeflow.py +++ b/pandapipes/pipeflow.py @@ -13,9 +13,8 @@ from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, \ init_options, create_internal_results, write_internal_results, get_lookup, create_lookups, \ initialize_pit, reduce_pit, set_user_pf_options, init_all_result_tables, \ - identify_active_nodes_branches + identify_active_nodes_branches, PipeflowNotConverged from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit -from pandapower.auxiliary import ppException try: import pandaplan.core.pplog as logging @@ -80,12 +79,9 @@ def pipeflow(net, sol_vec=None, **kwargs): calculate_hydraulics = calculation_mode in ["hydraulics", "all"] calculate_heat = calculation_mode in ["heat", "all"] - active_node_pit, active_branch_pit = identify_active_nodes_branches(net, branch_pit, node_pit) - - if (len(active_node_pit) == 0): - logger.warning(" All nodes are out of service. Probably they are not supplied." - " Have you forgotten to define an external grid?") - return + # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also required to + # determine the active node/branch heat transfer lookup + identify_active_nodes_branches(net, branch_pit, node_pit) if calculation_mode == "heat": if not net.user_pf_options["hyd_flag"]: @@ -364,10 +360,3 @@ def log_final_results(net, niter, residual_norm, hyraulic_mode=True): logger.debug("Norm of residual: %s" % residual_norm) for out in outputs: logger.debug("%s: %s" % (out, get_net_option(net, out))) - - -class PipeflowNotConverged(ppException): - """ - Exception being raised in case pipeflow did not converge. - """ - pass diff --git a/pandapipes/test/pipeflow_internals/test_inservice.py b/pandapipes/test/pipeflow_internals/test_inservice.py index 54acfaf78..d9dd025a6 100644 --- a/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/pandapipes/test/pipeflow_internals/test_inservice.py @@ -126,7 +126,7 @@ def create_mixed_indexing_grid(): @pytest.fixture -def create_net_wo_external_hydraulic_grid(): +def create_net_wo_ext_grid(): net = pandapipes.create_empty_network("net", add_stdtypes=False) pandapipes.create_fluid_from_lib(net, "hgas", overwrite=True) pandapipes.create_junction(net, index=3, pn_bar=16, tfluid_k=283, height_m=0, @@ -144,7 +144,6 @@ def create_net_wo_external_hydraulic_grid(): pandapipes.create_source(net, junction=10, mdot_kg_per_s=0.04, name="Source 3") pandapipes.create_compressor(net, from_junction=9, to_junction=3, pressure_ratio=1.1, name="Compressor 0", index=None, in_service=True) - pandapipes.create_ext_grid(net, junction=3, t_k=300) return net @@ -606,15 +605,24 @@ def test_mixed_indexing_oos6(create_mixed_indexing_grid, use_numba): @pytest.mark.parametrize("use_numba", [True, False]) -def test_pipeflow_cancellation(create_net_wo_external_hydraulic_grid, use_numba): - net = create_net_wo_external_hydraulic_grid - pandapipes.pipeflow(net) - assert np.all(np.isnan(net.res_junction)) - assert np.all(np.isnan(net.res_pipe)) - assert np.all(np.isnan(net.res_ext_grid)) - assert np.all(np.isnan(net.res_sink)) - assert np.all(np.isnan(net.res_source)) - assert np.all(np.isnan(net.res_compressor)) +def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): + net = create_net_wo_ext_grid + ex1 = pandapipes.create_ext_grid(net, junction=3, t_k=300) + ex2 = pandapipes.create_ext_grid(net, junction=3, p_bar=1) + with pytest.raises(PipeflowNotConverged): + net.ext_grid.at[ex2, 'in_service'] = False + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + use_numba=use_numba, check_connectivity=True) + net.ext_grid.at[ex1, 'in_service'] = False + net.ext_grid.at[ex2, 'in_service'] = True + + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + use_numba=use_numba, check_connectivity=True) + assert not np.all(np.isnan(net.res_junction.p_bar.values)) + + with pytest.raises(PipeflowNotConverged): + pandapipes.pipeflow(net, mode='all', iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + use_numba=use_numba, check_connectivity=True) if __name__ == "__main__": diff --git a/pandapipes/timeseries/run_time_series.py b/pandapipes/timeseries/run_time_series.py index beab805e1..590608df4 100644 --- a/pandapipes/timeseries/run_time_series.py +++ b/pandapipes/timeseries/run_time_series.py @@ -5,20 +5,19 @@ import tempfile from pandapower.control import NetCalculationNotConverged - -from pandapipes.pipeflow import PipeflowNotConverged, pipeflow from pandapower.control.util.diagnostic import control_diagnostic from pandapower.timeseries.output_writer import OutputWriter -from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup,\ +from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup, \ run_loop +from pandapipes.pipeflow import PipeflowNotConverged, pipeflow + try: import pandaplan.core.pplog as logging except ImportError: import logging logger = logging.getLogger(__name__) -logger.setLevel(level=logging.WARNING) def init_default_outputwriter(net, time_steps, **kwargs): From fc285771305e16018f196bb2d8c228e2a8270c27 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 19 Dec 2023 13:19:56 +0100 Subject: [PATCH 051/237] - assert the net.converged is set correctly --- pandapipes/test/pipeflow_internals/test_inservice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandapipes/test/pipeflow_internals/test_inservice.py b/pandapipes/test/pipeflow_internals/test_inservice.py index d9dd025a6..f7521d0db 100644 --- a/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/pandapipes/test/pipeflow_internals/test_inservice.py @@ -613,16 +613,19 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): net.ext_grid.at[ex2, 'in_service'] = False pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) + assert ~net.converged net.ext_grid.at[ex1, 'in_service'] = False net.ext_grid.at[ex2, 'in_service'] = True pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert not np.all(np.isnan(net.res_junction.p_bar.values)) + assert net.converged with pytest.raises(PipeflowNotConverged): pandapipes.pipeflow(net, mode='all', iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) + assert ~net.converged if __name__ == "__main__": From 60761fb7454c4520134096d8daa51bd8cc1ff877 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 12:53:12 +0100 Subject: [PATCH 052/237] clean repo and adapt changelog slightly --- CHANGELOG.rst | 1 + .../multinet/timeseries/run_time_series_multinet.py | 11 ++++++----- .../biomethane_pure/lower_heating_value.txt | 0 .../biomethane_treated/lower_heating_value.txt | 0 4 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 src/pandapipes/properties/biomethane_pure/lower_heating_value.txt delete mode 100644 src/pandapipes/properties/biomethane_treated/lower_heating_value.txt diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 58ff9bc6f..cd80ea5df 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Change Log ------------------------------- - [ADDED] multiple creation of heat exchanger - [ADDED] support Python 3.11 (now included in test pipeline) +- [ADDED] after the connectivity check, intercept the pipeflow if no more nodes are in-service (heat and hydraulic) - [CHANGED] dropped support for Python 3.7 (no longer included in test pipeline) - [CHANGED] connectivity check now separated by hydraulics and heat_transfer calculation, so that also results can differ in some rows (NaN or not) - [CHANGED] dynamic creation of lookups for getting pit as pandas tables diff --git a/src/pandapipes/multinet/timeseries/run_time_series_multinet.py b/src/pandapipes/multinet/timeseries/run_time_series_multinet.py index 7394a7780..f3697022c 100644 --- a/src/pandapipes/multinet/timeseries/run_time_series_multinet.py +++ b/src/pandapipes/multinet/timeseries/run_time_series_multinet.py @@ -3,6 +3,8 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import tqdm +from pandapipes.multinet.control.run_control_multinet import prepare_run_ctrl, run_control +from pandapipes.timeseries.run_time_series import init_default_outputwriter as init_default_ow_pps from pandapower import pandapowerNet from pandapower.control.util.diagnostic import control_diagnostic from pandapower.timeseries.run_time_series import get_recycle_settings, init_time_steps, \ @@ -10,8 +12,6 @@ init_output_writer from pandapipes import pandapipesNet -from pandapipes.multinet.control.run_control_multinet import prepare_run_ctrl, run_control -from pandapipes.timeseries.run_time_series import init_default_outputwriter as init_default_ow_pps try: import pandaplan.core.pplog as pplog @@ -19,7 +19,6 @@ import logging as pplog logger = pplog.getLogger(__name__) -logger.setLevel(level=pplog.WARNING) def _call_output_writer(multinet, time_step, pf_converged, ctrl_converged, ts_variables): @@ -41,7 +40,8 @@ def _call_output_writer(multinet, time_step, pf_converged, ctrl_converged, ts_va """ for net_name in multinet['nets'].keys(): net = multinet['nets'][net_name] - output_writer_routine(net, time_step, pf_converged, ctrl_converged, ts_variables['nets'][net_name]["recycle_options"]) + output_writer_routine(net, time_step, pf_converged, ctrl_converged, + ts_variables['nets'][net_name]["recycle_options"]) def init_time_series(multinet, time_steps, continue_on_divergence=False, verbose=True, @@ -81,7 +81,8 @@ def init_time_series(multinet, time_steps, continue_on_divergence=False, verbose if hasattr(run, "__name__") and run.__name__ == "runpp": # use faster runpp options if possible recycle_options = get_recycle_settings(net, **kwargs) - ts_variables['nets'][net_name]['run'] = run[net_name] if run is not None else ts_variables['nets'][net_name]['run'] + ts_variables['nets'][net_name]['run'] = run[ + net_name] if run is not None else ts_variables['nets'][net_name]['run'] ts_variables['nets'][net_name]['recycle_options'] = recycle_options init_output_writer(net, time_steps) diff --git a/src/pandapipes/properties/biomethane_pure/lower_heating_value.txt b/src/pandapipes/properties/biomethane_pure/lower_heating_value.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/pandapipes/properties/biomethane_treated/lower_heating_value.txt b/src/pandapipes/properties/biomethane_treated/lower_heating_value.txt deleted file mode 100644 index e69de29bb..000000000 From 9ee69d823458367719020b2598ccec18940eb1bc Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 21 Dec 2023 13:17:01 +0100 Subject: [PATCH 053/237] -changed copyright year --- doc/source/conf.py | 2 +- setup.py | 2 +- src/pandapipes/__init__.py | 2 +- src/pandapipes/component_models/__init__.py | 2 +- .../component_models/circulation_pump_mass_component.py | 2 +- .../component_models/circulation_pump_pressure_component.py | 2 +- src/pandapipes/component_models/component_toolbox.py | 2 +- src/pandapipes/component_models/compressor_component.py | 2 +- src/pandapipes/component_models/ext_grid_component.py | 2 +- src/pandapipes/component_models/flow_control_component.py | 2 +- src/pandapipes/component_models/heat_exchanger_component.py | 2 +- src/pandapipes/component_models/junction_component.py | 2 +- src/pandapipes/component_models/mass_storage_component.py | 2 +- src/pandapipes/component_models/pipe_component.py | 2 +- src/pandapipes/component_models/pressure_control_component.py | 2 +- src/pandapipes/component_models/pump_component.py | 2 +- src/pandapipes/component_models/sink_component.py | 2 +- src/pandapipes/component_models/source_component.py | 2 +- src/pandapipes/component_models/valve_component.py | 2 +- src/pandapipes/constants.py | 2 +- src/pandapipes/control/__init__.py | 2 +- src/pandapipes/control/run_control.py | 2 +- src/pandapipes/converter/__init__.py | 2 +- src/pandapipes/create.py | 2 +- src/pandapipes/idx_branch.py | 2 +- src/pandapipes/idx_node.py | 2 +- src/pandapipes/io/__init__.py | 2 +- src/pandapipes/io/convert_format.py | 2 +- src/pandapipes/io/file_io.py | 2 +- src/pandapipes/io/io_utils.py | 2 +- src/pandapipes/multinet/__init__.py | 2 +- src/pandapipes/multinet/control/__init__.py | 2 +- src/pandapipes/multinet/control/run_control_multinet.py | 2 +- src/pandapipes/multinet/create_multinet.py | 2 +- src/pandapipes/multinet/multinet.py | 2 +- src/pandapipes/multinet/timeseries/__init__.py | 2 +- src/pandapipes/multinet/timeseries/run_time_series_multinet.py | 2 +- src/pandapipes/networks/nw_aux.py | 2 +- src/pandapipes/networks/simple_gas_networks.py | 2 +- src/pandapipes/networks/simple_heat_transfer_networks.py | 2 +- src/pandapipes/pandapipes_net.py | 2 +- src/pandapipes/pf/__init__.py | 2 +- src/pandapipes/pf/build_system_matrix.py | 2 +- src/pandapipes/pf/derivative_toolbox.py | 2 +- src/pandapipes/pf/internals_toolbox.py | 2 +- src/pandapipes/pf/pipeflow_setup.py | 2 +- src/pandapipes/pipeflow.py | 2 +- src/pandapipes/plotting/generic_geodata.py | 2 +- src/pandapipes/plotting/patch_makers.py | 2 +- src/pandapipes/plotting/pipeflow_results.py | 2 +- src/pandapipes/properties/__init__.py | 2 +- src/pandapipes/properties/properties_toolbox.py | 2 +- src/pandapipes/test/__init__.py | 2 +- src/pandapipes/test/api/__init__.py | 2 +- src/pandapipes/test/api/test_aux_function.py | 2 +- src/pandapipes/test/api/test_convert_format.py | 2 +- src/pandapipes/test/api/test_create.py | 2 +- src/pandapipes/test/api/test_network_tables.py | 2 +- src/pandapipes/test/api/test_special_networks.py | 2 +- src/pandapipes/test/api/test_std_types.py | 2 +- src/pandapipes/test/io/__init__.py | 2 +- src/pandapipes/test/io/test_file_io.py | 2 +- src/pandapipes/test/multinet/__init__.py | 2 +- src/pandapipes/test/multinet/test_control_multinet.py | 2 +- src/pandapipes/test/multinet/test_time_series_multinet.py | 2 +- src/pandapipes/test/networks/__init__.py | 2 +- src/pandapipes/test/networks/test_networks.py | 2 +- src/pandapipes/test/openmodelica_comparison/__init__.py | 2 +- .../openmodelica_comparison/pipeflow_openmodelica_comparison.py | 2 +- .../openmodelica_comparison/test_heat_transfer_openmodelica.py | 2 +- .../test/openmodelica_comparison/test_water_openmodelica.py | 2 +- src/pandapipes/test/pipeflow_internals/__init__.py | 2 +- src/pandapipes/test/pipeflow_internals/test_inservice.py | 2 +- src/pandapipes/test/pipeflow_internals/test_non_convergence.py | 2 +- src/pandapipes/test/pipeflow_internals/test_options.py | 2 +- .../pipeflow_internals/test_pipeflow_analytic_comparison.py | 2 +- src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py | 2 +- src/pandapipes/test/pipeflow_internals/test_time_series.py | 2 +- src/pandapipes/test/pipeflow_internals/test_update_matrix.py | 2 +- src/pandapipes/test/plotting/__init__.py | 2 +- src/pandapipes/test/plotting/test_collections.py | 2 +- src/pandapipes/test/plotting/test_generic_coordinates.py | 2 +- src/pandapipes/test/plotting/test_pipeflow_results.py | 2 +- src/pandapipes/test/plotting/test_simple_collections.py | 2 +- src/pandapipes/test/properties/__init__.py | 2 +- src/pandapipes/test/properties/test_fluid_specials.py | 2 +- src/pandapipes/test/properties/test_properties_toolbox.py | 2 +- src/pandapipes/test/run_tests.py | 2 +- src/pandapipes/test/stanet_comparison/__init__.py | 2 +- .../test/stanet_comparison/pipeflow_stanet_comparison.py | 2 +- src/pandapipes/test/stanet_comparison/test_gas_stanet.py | 2 +- src/pandapipes/test/stanet_comparison/test_water_stanet.py | 2 +- src/pandapipes/test/test_imports.py | 2 +- src/pandapipes/test/test_toolbox.py | 2 +- src/pandapipes/test/topology/__init__.py | 2 +- src/pandapipes/test/topology/test_graph_searches.py | 2 +- src/pandapipes/test/topology/test_nxgraph.py | 2 +- src/pandapipes/timeseries/__init__.py | 2 +- src/pandapipes/timeseries/run_time_series.py | 2 +- src/pandapipes/toolbox.py | 2 +- 100 files changed, 100 insertions(+), 100 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 5738f187f..f838d1fe1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -23,7 +23,7 @@ # -- Project information ----------------------------------------------------- project = 'pandapipes' -copyright = '2020-2023 by Fraunhofer Institute for Energy Economics \ +copyright = '2020-2024 by Fraunhofer Institute for Energy Economics \ and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.' diff --git a/setup.py b/setup.py index 46526a0b4..0a230161e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index 371d6941b..045b0804e 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/__init__.py b/src/pandapipes/component_models/__init__.py index 279803d28..3437b0c3a 100644 --- a/src/pandapipes/component_models/__init__.py +++ b/src/pandapipes/component_models/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/circulation_pump_mass_component.py b/src/pandapipes/component_models/circulation_pump_mass_component.py index 699d1e416..39cdb217b 100644 --- a/src/pandapipes/component_models/circulation_pump_mass_component.py +++ b/src/pandapipes/component_models/circulation_pump_mass_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/circulation_pump_pressure_component.py b/src/pandapipes/component_models/circulation_pump_pressure_component.py index 6cfbf2eb9..fb7ff2af3 100644 --- a/src/pandapipes/component_models/circulation_pump_pressure_component.py +++ b/src/pandapipes/component_models/circulation_pump_pressure_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 305261437..840929bc4 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/compressor_component.py b/src/pandapipes/component_models/compressor_component.py index d9d5e8113..a65372d7a 100644 --- a/src/pandapipes/component_models/compressor_component.py +++ b/src/pandapipes/component_models/compressor_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/ext_grid_component.py b/src/pandapipes/component_models/ext_grid_component.py index d78028320..2e1d9e792 100644 --- a/src/pandapipes/component_models/ext_grid_component.py +++ b/src/pandapipes/component_models/ext_grid_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py index 67e25487e..f4b88388b 100644 --- a/src/pandapipes/component_models/flow_control_component.py +++ b/src/pandapipes/component_models/flow_control_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index d958fda94..92c8b4b9b 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/junction_component.py b/src/pandapipes/component_models/junction_component.py index fdf2a22ab..7a1cce558 100644 --- a/src/pandapipes/component_models/junction_component.py +++ b/src/pandapipes/component_models/junction_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/mass_storage_component.py b/src/pandapipes/component_models/mass_storage_component.py index 8ece4255b..234bf23e9 100644 --- a/src/pandapipes/component_models/mass_storage_component.py +++ b/src/pandapipes/component_models/mass_storage_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. from pandapipes.component_models.junction_component import Junction diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 99b2f098a..550eb1ff1 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py index e582925bb..1c5aad2e7 100644 --- a/src/pandapipes/component_models/pressure_control_component.py +++ b/src/pandapipes/component_models/pressure_control_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index 715332f69..411209a2b 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/sink_component.py b/src/pandapipes/component_models/sink_component.py index 3b0e30d90..0f016e367 100644 --- a/src/pandapipes/component_models/sink_component.py +++ b/src/pandapipes/component_models/sink_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. from pandapipes.component_models.junction_component import Junction diff --git a/src/pandapipes/component_models/source_component.py b/src/pandapipes/component_models/source_component.py index 54ade9cd8..f93755a83 100644 --- a/src/pandapipes/component_models/source_component.py +++ b/src/pandapipes/component_models/source_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. from pandapipes.component_models.junction_component import Junction diff --git a/src/pandapipes/component_models/valve_component.py b/src/pandapipes/component_models/valve_component.py index ff2b9451e..b88403361 100644 --- a/src/pandapipes/component_models/valve_component.py +++ b/src/pandapipes/component_models/valve_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/constants.py b/src/pandapipes/constants.py index 0b3c5575e..333f17a2b 100644 --- a/src/pandapipes/constants.py +++ b/src/pandapipes/constants.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/control/__init__.py b/src/pandapipes/control/__init__.py index 8446d8ec5..5970c1f92 100644 --- a/src/pandapipes/control/__init__.py +++ b/src/pandapipes/control/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/control/run_control.py b/src/pandapipes/control/run_control.py index dbd631345..4b5ac1671 100644 --- a/src/pandapipes/control/run_control.py +++ b/src/pandapipes/control/run_control.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/__init__.py b/src/pandapipes/converter/__init__.py index d49f669e0..88d36891d 100644 --- a/src/pandapipes/converter/__init__.py +++ b/src/pandapipes/converter/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index dd3746ff5..777265c3b 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py index c4e3c1632..5104ea279 100644 --- a/src/pandapipes/idx_branch.py +++ b/src/pandapipes/idx_branch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/idx_node.py b/src/pandapipes/idx_node.py index 0cf71b5a2..49726cf30 100644 --- a/src/pandapipes/idx_node.py +++ b/src/pandapipes/idx_node.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/io/__init__.py b/src/pandapipes/io/__init__.py index 3d30a8959..c3be3a4de 100644 --- a/src/pandapipes/io/__init__.py +++ b/src/pandapipes/io/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py index ce13afa07..a4c8b0a45 100644 --- a/src/pandapipes/io/convert_format.py +++ b/src/pandapipes/io/convert_format.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/io/file_io.py b/src/pandapipes/io/file_io.py index a1aa0a86c..d50b59f10 100644 --- a/src/pandapipes/io/file_io.py +++ b/src/pandapipes/io/file_io.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/io/io_utils.py b/src/pandapipes/io/io_utils.py index 745ee3d1b..54afe4f6c 100644 --- a/src/pandapipes/io/io_utils.py +++ b/src/pandapipes/io/io_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/__init__.py b/src/pandapipes/multinet/__init__.py index b4e3f9260..cc2498984 100644 --- a/src/pandapipes/multinet/__init__.py +++ b/src/pandapipes/multinet/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/control/__init__.py b/src/pandapipes/multinet/control/__init__.py index dcd809478..9fff6cee5 100644 --- a/src/pandapipes/multinet/control/__init__.py +++ b/src/pandapipes/multinet/control/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/control/run_control_multinet.py b/src/pandapipes/multinet/control/run_control_multinet.py index 9debef933..a68c94c21 100644 --- a/src/pandapipes/multinet/control/run_control_multinet.py +++ b/src/pandapipes/multinet/control/run_control_multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/multinet/create_multinet.py b/src/pandapipes/multinet/create_multinet.py index 64a31df44..98e19e093 100644 --- a/src/pandapipes/multinet/create_multinet.py +++ b/src/pandapipes/multinet/create_multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/multinet/multinet.py b/src/pandapipes/multinet/multinet.py index 0894fde1e..6468bb5f6 100644 --- a/src/pandapipes/multinet/multinet.py +++ b/src/pandapipes/multinet/multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/multinet/timeseries/__init__.py b/src/pandapipes/multinet/timeseries/__init__.py index d29dcf849..ca4ee1afb 100644 --- a/src/pandapipes/multinet/timeseries/__init__.py +++ b/src/pandapipes/multinet/timeseries/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/timeseries/run_time_series_multinet.py b/src/pandapipes/multinet/timeseries/run_time_series_multinet.py index f3697022c..2eb9a22b8 100644 --- a/src/pandapipes/multinet/timeseries/run_time_series_multinet.py +++ b/src/pandapipes/multinet/timeseries/run_time_series_multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/networks/nw_aux.py b/src/pandapipes/networks/nw_aux.py index 88e3a512d..ce1c58e04 100644 --- a/src/pandapipes/networks/nw_aux.py +++ b/src/pandapipes/networks/nw_aux.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/networks/simple_gas_networks.py b/src/pandapipes/networks/simple_gas_networks.py index b7e6003c3..55065d650 100644 --- a/src/pandapipes/networks/simple_gas_networks.py +++ b/src/pandapipes/networks/simple_gas_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/networks/simple_heat_transfer_networks.py b/src/pandapipes/networks/simple_heat_transfer_networks.py index a7380448d..f46566648 100644 --- a/src/pandapipes/networks/simple_heat_transfer_networks.py +++ b/src/pandapipes/networks/simple_heat_transfer_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pandapipes_net.py b/src/pandapipes/pandapipes_net.py index 8d4a7488d..bcd4be389 100644 --- a/src/pandapipes/pandapipes_net.py +++ b/src/pandapipes/pandapipes_net.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pf/__init__.py b/src/pandapipes/pf/__init__.py index 1b5988cb0..df963e35b 100644 --- a/src/pandapipes/pf/__init__.py +++ b/src/pandapipes/pf/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index 454e9b771..e388d2f84 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index 8ee435712..bbfd7dadb 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pf/internals_toolbox.py b/src/pandapipes/pf/internals_toolbox.py index 5732ad2f4..8e094476f 100644 --- a/src/pandapipes/pf/internals_toolbox.py +++ b/src/pandapipes/pf/internals_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 1b314a462..91c2c6b25 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 4dab2f9f1..9d78a84e5 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/generic_geodata.py b/src/pandapipes/plotting/generic_geodata.py index a158651d8..51bc2cd2d 100644 --- a/src/pandapipes/plotting/generic_geodata.py +++ b/src/pandapipes/plotting/generic_geodata.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py index 29bf4bacd..3c6950ca0 100644 --- a/src/pandapipes/plotting/patch_makers.py +++ b/src/pandapipes/plotting/patch_makers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index f9ac2f78d..520c2cb5f 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/properties/__init__.py b/src/pandapipes/properties/__init__.py index 9274adeeb..9c85266f4 100644 --- a/src/pandapipes/properties/__init__.py +++ b/src/pandapipes/properties/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index 4c34690d5..52b9b85eb 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/__init__.py b/src/pandapipes/test/__init__.py index 32bfcc872..c22811717 100644 --- a/src/pandapipes/test/__init__.py +++ b/src/pandapipes/test/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/__init__.py b/src/pandapipes/test/api/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/api/__init__.py +++ b/src/pandapipes/test/api/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_aux_function.py b/src/pandapipes/test/api/test_aux_function.py index e677bf10d..7fb1fa305 100644 --- a/src/pandapipes/test/api/test_aux_function.py +++ b/src/pandapipes/test/api/test_aux_function.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_convert_format.py b/src/pandapipes/test/api/test_convert_format.py index b58fbe03a..f96b2b0b9 100644 --- a/src/pandapipes/test/api/test_convert_format.py +++ b/src/pandapipes/test/api/test_convert_format.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_create.py b/src/pandapipes/test/api/test_create.py index b2dff8c97..50fe21f6b 100644 --- a/src/pandapipes/test/api/test_create.py +++ b/src/pandapipes/test/api/test_create.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_network_tables.py b/src/pandapipes/test/api/test_network_tables.py index 899f1bacd..8ee1510bf 100644 --- a/src/pandapipes/test/api/test_network_tables.py +++ b/src/pandapipes/test/api/test_network_tables.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_special_networks.py b/src/pandapipes/test/api/test_special_networks.py index 1b09cd661..f577a846b 100644 --- a/src/pandapipes/test/api/test_special_networks.py +++ b/src/pandapipes/test/api/test_special_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_std_types.py b/src/pandapipes/test/api/test_std_types.py index e1bfcca12..b65da82d9 100644 --- a/src/pandapipes/test/api/test_std_types.py +++ b/src/pandapipes/test/api/test_std_types.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/io/__init__.py b/src/pandapipes/test/io/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/io/__init__.py +++ b/src/pandapipes/test/io/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/io/test_file_io.py b/src/pandapipes/test/io/test_file_io.py index a3c3299c0..de3b042f8 100644 --- a/src/pandapipes/test/io/test_file_io.py +++ b/src/pandapipes/test/io/test_file_io.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/multinet/__init__.py b/src/pandapipes/test/multinet/__init__.py index a42db6204..007099182 100644 --- a/src/pandapipes/test/multinet/__init__.py +++ b/src/pandapipes/test/multinet/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/test/multinet/test_control_multinet.py b/src/pandapipes/test/multinet/test_control_multinet.py index d7540c7ce..8bfc88fa9 100644 --- a/src/pandapipes/test/multinet/test_control_multinet.py +++ b/src/pandapipes/test/multinet/test_control_multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/test/multinet/test_time_series_multinet.py b/src/pandapipes/test/multinet/test_time_series_multinet.py index 32deb3597..63ac5348b 100644 --- a/src/pandapipes/test/multinet/test_time_series_multinet.py +++ b/src/pandapipes/test/multinet/test_time_series_multinet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/test/networks/__init__.py b/src/pandapipes/test/networks/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/networks/__init__.py +++ b/src/pandapipes/test/networks/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/networks/test_networks.py b/src/pandapipes/test/networks/test_networks.py index 5d50c1d6d..0aae9dea8 100644 --- a/src/pandapipes/test/networks/test_networks.py +++ b/src/pandapipes/test/networks/test_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/openmodelica_comparison/__init__.py b/src/pandapipes/test/openmodelica_comparison/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/openmodelica_comparison/__init__.py +++ b/src/pandapipes/test/openmodelica_comparison/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py index 28c021296..0fe9eb95d 100644 --- a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py +++ b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py index 713866c8b..b7ccd6dc6 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py index 8d9f27c0b..7f9c54827 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/__init__.py b/src/pandapipes/test/pipeflow_internals/__init__.py index 103517367..1d23cb89e 100644 --- a/src/pandapipes/test/pipeflow_internals/__init__.py +++ b/src/pandapipes/test/pipeflow_internals/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 1a5fd17a8..2768f1ea8 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_non_convergence.py b/src/pandapipes/test/pipeflow_internals/test_non_convergence.py index 89f2e9de6..4c365d650 100644 --- a/src/pandapipes/test/pipeflow_internals/test_non_convergence.py +++ b/src/pandapipes/test/pipeflow_internals/test_non_convergence.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index 1e47b2508..3765a32df 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 3ad196701..de52ce872 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index d722711ab..267dec5db 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_time_series.py b/src/pandapipes/test/pipeflow_internals/test_time_series.py index afb0276da..30ff113e6 100644 --- a/src/pandapipes/test/pipeflow_internals/test_time_series.py +++ b/src/pandapipes/test/pipeflow_internals/test_time_series.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/pipeflow_internals/test_update_matrix.py b/src/pandapipes/test/pipeflow_internals/test_update_matrix.py index 38c16e6a3..e0e5ee1f4 100644 --- a/src/pandapipes/test/pipeflow_internals/test_update_matrix.py +++ b/src/pandapipes/test/pipeflow_internals/test_update_matrix.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/plotting/__init__.py b/src/pandapipes/test/plotting/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/plotting/__init__.py +++ b/src/pandapipes/test/plotting/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/plotting/test_collections.py b/src/pandapipes/test/plotting/test_collections.py index 19011d6c6..5c3cd9014 100644 --- a/src/pandapipes/test/plotting/test_collections.py +++ b/src/pandapipes/test/plotting/test_collections.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/plotting/test_generic_coordinates.py b/src/pandapipes/test/plotting/test_generic_coordinates.py index 5a78800f0..9c18a0738 100644 --- a/src/pandapipes/test/plotting/test_generic_coordinates.py +++ b/src/pandapipes/test/plotting/test_generic_coordinates.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/plotting/test_pipeflow_results.py b/src/pandapipes/test/plotting/test_pipeflow_results.py index 5e288938f..05fa3558e 100644 --- a/src/pandapipes/test/plotting/test_pipeflow_results.py +++ b/src/pandapipes/test/plotting/test_pipeflow_results.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/plotting/test_simple_collections.py b/src/pandapipes/test/plotting/test_simple_collections.py index a1d231b95..5de8829bd 100644 --- a/src/pandapipes/test/plotting/test_simple_collections.py +++ b/src/pandapipes/test/plotting/test_simple_collections.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/properties/__init__.py b/src/pandapipes/test/properties/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/properties/__init__.py +++ b/src/pandapipes/test/properties/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/properties/test_fluid_specials.py b/src/pandapipes/test/properties/test_fluid_specials.py index faa1ca14a..56cd2f5ac 100644 --- a/src/pandapipes/test/properties/test_fluid_specials.py +++ b/src/pandapipes/test/properties/test_fluid_specials.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/properties/test_properties_toolbox.py b/src/pandapipes/test/properties/test_properties_toolbox.py index 4a1de2ab6..db6d0ecd6 100644 --- a/src/pandapipes/test/properties/test_properties_toolbox.py +++ b/src/pandapipes/test/properties/test_properties_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/run_tests.py b/src/pandapipes/test/run_tests.py index 25d0531fe..59acfcd37 100644 --- a/src/pandapipes/test/run_tests.py +++ b/src/pandapipes/test/run_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/stanet_comparison/__init__.py b/src/pandapipes/test/stanet_comparison/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/stanet_comparison/__init__.py +++ b/src/pandapipes/test/stanet_comparison/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py index 9556a3c98..451d9c3af 100644 --- a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py +++ b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py index 0e37afd3d..0abdd70ca 100644 --- a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/stanet_comparison/test_water_stanet.py b/src/pandapipes/test/stanet_comparison/test_water_stanet.py index 0b5cf66d6..0c7976e25 100644 --- a/src/pandapipes/test/stanet_comparison/test_water_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_water_stanet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/test_imports.py b/src/pandapipes/test/test_imports.py index 865507b01..ce19339d8 100644 --- a/src/pandapipes/test/test_imports.py +++ b/src/pandapipes/test/test_imports.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py index 2c5bc1ae6..973d30895 100644 --- a/src/pandapipes/test/test_toolbox.py +++ b/src/pandapipes/test/test_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/topology/__init__.py b/src/pandapipes/test/topology/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/topology/__init__.py +++ b/src/pandapipes/test/topology/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/topology/test_graph_searches.py b/src/pandapipes/test/topology/test_graph_searches.py index caadb48cf..404e5c889 100644 --- a/src/pandapipes/test/topology/test_graph_searches.py +++ b/src/pandapipes/test/topology/test_graph_searches.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/topology/test_nxgraph.py b/src/pandapipes/test/topology/test_nxgraph.py index 62a7e12ab..29bed573f 100644 --- a/src/pandapipes/test/topology/test_nxgraph.py +++ b/src/pandapipes/test/topology/test_nxgraph.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/timeseries/__init__.py b/src/pandapipes/timeseries/__init__.py index 83f8d986a..07b604ed8 100644 --- a/src/pandapipes/timeseries/__init__.py +++ b/src/pandapipes/timeseries/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/timeseries/run_time_series.py b/src/pandapipes/timeseries/run_time_series.py index 590608df4..03ff9dd77 100644 --- a/src/pandapipes/timeseries/run_time_series.py +++ b/src/pandapipes/timeseries/run_time_series.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/toolbox.py b/src/pandapipes/toolbox.py index 7f6c1fb53..e0b5d2565 100644 --- a/src/pandapipes/toolbox.py +++ b/src/pandapipes/toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 copy From cd2f27d896bf38bc1b6deef60d5a31eb62772cf6 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 13:21:47 +0100 Subject: [PATCH 054/237] using always python -m in workflows --- .github/workflows/release.yml | 6 +++--- .github/workflows/run_tests_develop.yml | 14 +++++++------- .github/workflows/run_tests_master.yml | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30a659782..a583ac9a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,14 +90,14 @@ jobs: - name: Install pandapipes from TestPyPI if: ${{ inputs.upload_server == 'testpypi'}} run: | - pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pandapipes + python -m pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pandapipes - name: Install pandapipes from PyPI if: ${{ inputs.upload_server == 'pypi'}} run: | - pip install pandapipes + python -m pip install pandapipes - name: List all installed packages run: | - pip list + python -m pip list - name: Test with pytest run: | pytest --pyargs pandapipes.test diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index d1ea95dbf..b0bcb60e2 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -32,19 +32,19 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install . + python -m pip install . - name: List all installed packages run: | - pip list + python -m pip list - name: Test with pytest if: ${{ matrix.python-version != '3.9' }} run: | - pytest + python -m pytest - name: Test with pytest and Codecov if: ${{ matrix.python-version == '3.9' }} run: | python -m pip install pytest-cov - pytest --cov=./ --cov-report=xml + python -m pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v1 @@ -70,10 +70,10 @@ jobs: python -m pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - pip install . + python -m pip install . - name: List all installed packages run: | - pip list + python -m pip list - name: Lint with flake8 (syntax errors and undefinded names) run: | # stop the build if there are Python syntax errors or undefined names @@ -104,7 +104,7 @@ jobs: python -m pip install . - name: List all installed packages run: | - pip list + python -m pip list - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index ad856db14..153a78694 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -32,19 +32,19 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; - pip install . + python -m pip install . - name: List all installed packages run: | - pip list + python -m pip list - name: Test with pytest if: ${{ matrix.python-version != '3.9' }} run: | - pytest + python -m pytest - name: Test with pytest and Codecov if: ${{ matrix.python-version == '3.9' }} run: | python -m pip install pytest-cov - pytest --cov=./ --cov-report=xml + python -m pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v1 @@ -69,13 +69,13 @@ jobs: if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower - pip install . + python -m pip install . - name: List all installed packages run: | - pip list + python -m pip list - name: Test with pytest run: | - pytest --nbmake -n=auto "./tutorials" + python -m pytest --nbmake -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest From c38ed6cd40fb163528b7b02c2864370dc768d65d Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 13:22:28 +0100 Subject: [PATCH 055/237] adapting version tag --- CHANGELOG.rst | 2 +- setup.py | 2 +- src/pandapipes/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cd80ea5df..185dacee5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change Log ============= -[upcoming release] - 2023-..-.. +[0.9.0] - 2023-12-22 ------------------------------- - [ADDED] multiple creation of heat exchanger - [ADDED] support Python 3.11 (now included in test pipeline) diff --git a/setup.py b/setup.py index 46526a0b4..bd9f12576 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( name='pandapipes', - version='0.8.5', + version='0.9.0', author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' 'jolando.kisse@uni-kassel.de', diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index 371d6941b..edec97fd7 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -2,7 +2,7 @@ # 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. -__version__ = '0.8.5' +__version__ = '0.9.0' __format_version__ = '0.8.0' import pandas as pd From 2f74032c762dd6faa21d0f2a11c174d88aa24d05 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 13:22:53 +0100 Subject: [PATCH 056/237] changing author name --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index b0fe8adbf..4670fec3b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,7 +3,7 @@ and Energy System Technology (IEE), Kassel, and University of Kassel. All rights Lead Developers: - Daniel Lohmeier - - Simon Ruben Drauz + - Simon Ruben Drauz-Mauel - Jolando Marius Kisse Main Contributors: From b461ce4b8a324da6857af239c8e8db45c67b14a8 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 13:23:08 +0100 Subject: [PATCH 057/237] adding src layout info in changelog --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 185dacee5..de161c8fc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,7 @@ Change Log - [CHANGED] dynamic creation of lookups for getting pit as pandas tables - [CHANGED] components can have their own internal arrays for specific calculations (e.g. for compressor pressure ratio), so that the pit does not need to include such component specific entries - [CHANGED] .readthedocs.yml due to deprecation +- [CHANGED] changing from setuptools flat-layout into src-layout - [FIXED] in STANET converter: bug fix for heat exchanger creation and external temperatures of pipes added - [REMOVED] broken travis badge removed from readme From 882c9143373121a4d8822b6f7db72dc8210ebbb4 Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 21 Dec 2023 13:50:59 +0100 Subject: [PATCH 058/237] -changed copyright year 2 --- AUTHORS | 2 +- CHANGELOG.rst | 1 + LICENSE | 2 +- src/pandapipes/component_models/abstract_models/__init__.py | 2 +- .../component_models/abstract_models/base_component.py | 2 +- .../component_models/abstract_models/branch_models.py | 2 +- .../abstract_models/branch_w_internals_models.py | 2 +- .../abstract_models/branch_wo_internals_models.py | 2 +- .../abstract_models/branch_wzerolength_models.py | 2 +- .../component_models/abstract_models/circulation_pump.py | 2 +- .../component_models/abstract_models/const_flow_models.py | 2 +- .../component_models/abstract_models/node_element_models.py | 2 +- src/pandapipes/component_models/abstract_models/node_models.py | 2 +- src/pandapipes/converter/stanet/__init__.py | 2 +- src/pandapipes/converter/stanet/data_cleaning.py | 2 +- src/pandapipes/converter/stanet/preparing_steps.py | 2 +- src/pandapipes/converter/stanet/stanet2pandapipes.py | 2 +- src/pandapipes/converter/stanet/table_creation.py | 2 +- .../converter/stanet/valve_pipe_component/__init__.py | 2 +- .../converter/stanet/valve_pipe_component/create_valve_pipe.py | 2 +- .../stanet/valve_pipe_component/valve_pipe_component.py | 2 +- .../stanet/valve_pipe_component/valve_pipe_plotting.py | 2 +- src/pandapipes/multinet/control/controller/__init__.py | 2 +- src/pandapipes/multinet/control/controller/multinet_control.py | 2 +- src/pandapipes/networks/__init__.py | 2 +- src/pandapipes/networks/simple_water_networks.py | 2 +- src/pandapipes/plotting/__init__.py | 2 +- src/pandapipes/plotting/collections.py | 2 +- src/pandapipes/plotting/geo.py | 2 +- src/pandapipes/plotting/plotting_toolbox.py | 2 +- src/pandapipes/plotting/simple_plot.py | 2 +- src/pandapipes/properties/fluids.py | 2 +- src/pandapipes/std_types/__init__.py | 2 +- src/pandapipes/std_types/std_type_class.py | 2 +- src/pandapipes/std_types/std_types.py | 2 +- .../test/api/release_cycle/release_control_test_network.py | 2 +- src/pandapipes/test/api/test_components/__init__.py | 2 +- src/pandapipes/test/api/test_components/test_circ_pump_mass.py | 2 +- .../test/api/test_components/test_circ_pump_pressure.py | 2 +- src/pandapipes/test/api/test_components/test_compressor.py | 2 +- src/pandapipes/test/api/test_components/test_ext_grid.py | 2 +- src/pandapipes/test/api/test_components/test_heat_exchanger.py | 2 +- src/pandapipes/test/api/test_components/test_mass_storage.py | 2 +- src/pandapipes/test/api/test_components/test_pipe_results.py | 2 +- .../test/api/test_components/test_pressure_control.py | 2 +- src/pandapipes/test/api/test_components/test_pump.py | 2 +- src/pandapipes/test/api/test_components/test_valve.py | 2 +- src/pandapipes/test/converter/test_stanet_converter.py | 2 +- src/pandapipes/topology/__init__.py | 2 +- src/pandapipes/topology/create_graph.py | 2 +- src/pandapipes/topology/graph_searches.py | 2 +- 51 files changed, 51 insertions(+), 50 deletions(-) diff --git a/AUTHORS b/AUTHORS index b0fe8adbf..07a8ee3a2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved. Lead Developers: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cd80ea5df..27cdd68c9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,7 @@ Change Log [upcoming release] - 2023-..-.. ------------------------------- + - [ADDED] multiple creation of heat exchanger - [ADDED] support Python 3.11 (now included in test pipeline) - [ADDED] after the connectivity check, intercept the pipeflow if no more nodes are in-service (heat and hydraulic) diff --git a/LICENSE b/LICENSE index 29e1621fc..5eac7ca2b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics and Energy System Technology (IEE), Kassel, and University of Kassel. Further contributions by individual contributors (see AUTHORS file for details). All rights reserved. diff --git a/src/pandapipes/component_models/abstract_models/__init__.py b/src/pandapipes/component_models/abstract_models/__init__.py index d0a791b81..2e1e01892 100644 --- a/src/pandapipes/component_models/abstract_models/__init__.py +++ b/src/pandapipes/component_models/abstract_models/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/base_component.py b/src/pandapipes/component_models/abstract_models/base_component.py index 105035f3d..50d6f5556 100644 --- a/src/pandapipes/component_models/abstract_models/base_component.py +++ b/src/pandapipes/component_models/abstract_models/base_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index f9d98d6e8..9516dcbb6 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py index 0478254a9..c21d7d582 100644 --- a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py index 2867c241b..1ec2589ab 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py b/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py index b9da3028f..a1668ab38 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/circulation_pump.py b/src/pandapipes/component_models/abstract_models/circulation_pump.py index 3c3e338de..dd18a9b6f 100644 --- a/src/pandapipes/component_models/abstract_models/circulation_pump.py +++ b/src/pandapipes/component_models/abstract_models/circulation_pump.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/const_flow_models.py b/src/pandapipes/component_models/abstract_models/const_flow_models.py index a10a4d0e4..665ba7046 100644 --- a/src/pandapipes/component_models/abstract_models/const_flow_models.py +++ b/src/pandapipes/component_models/abstract_models/const_flow_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/node_element_models.py b/src/pandapipes/component_models/abstract_models/node_element_models.py index 0792fa531..32db81212 100644 --- a/src/pandapipes/component_models/abstract_models/node_element_models.py +++ b/src/pandapipes/component_models/abstract_models/node_element_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/component_models/abstract_models/node_models.py b/src/pandapipes/component_models/abstract_models/node_models.py index 0ce18e4a9..7adc3ab2c 100644 --- a/src/pandapipes/component_models/abstract_models/node_models.py +++ b/src/pandapipes/component_models/abstract_models/node_models.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/__init__.py b/src/pandapipes/converter/stanet/__init__.py index 219b32db7..2b3f44de5 100644 --- a/src/pandapipes/converter/stanet/__init__.py +++ b/src/pandapipes/converter/stanet/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/data_cleaning.py b/src/pandapipes/converter/stanet/data_cleaning.py index f440be9c5..aa7389530 100644 --- a/src/pandapipes/converter/stanet/data_cleaning.py +++ b/src/pandapipes/converter/stanet/data_cleaning.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index 91e8b5b5e..43c190ffb 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/stanet2pandapipes.py b/src/pandapipes/converter/stanet/stanet2pandapipes.py index ed644f9f9..6bd2484d2 100644 --- a/src/pandapipes/converter/stanet/stanet2pandapipes.py +++ b/src/pandapipes/converter/stanet/stanet2pandapipes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/table_creation.py b/src/pandapipes/converter/stanet/table_creation.py index 7678b4c5d..280d3a64a 100644 --- a/src/pandapipes/converter/stanet/table_creation.py +++ b/src/pandapipes/converter/stanet/table_creation.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/__init__.py b/src/pandapipes/converter/stanet/valve_pipe_component/__init__.py index 875194cc9..dac40f186 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/__init__.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py b/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py index 9b6586dfb..8ab3fe6eb 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py index 6b7a5ed85..4dc085eb4 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py index 7b3d780d9..16592eda6 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/control/controller/__init__.py b/src/pandapipes/multinet/control/controller/__init__.py index 835acc1d4..f03f3e1df 100644 --- a/src/pandapipes/multinet/control/controller/__init__.py +++ b/src/pandapipes/multinet/control/controller/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/multinet/control/controller/multinet_control.py b/src/pandapipes/multinet/control/controller/multinet_control.py index 72300b93b..0dedb94a8 100644 --- a/src/pandapipes/multinet/control/controller/multinet_control.py +++ b/src/pandapipes/multinet/control/controller/multinet_control.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/networks/__init__.py b/src/pandapipes/networks/__init__.py index 562561b5c..ba400eca3 100644 --- a/src/pandapipes/networks/__init__.py +++ b/src/pandapipes/networks/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/networks/simple_water_networks.py b/src/pandapipes/networks/simple_water_networks.py index 629bb0cd4..b0e8bd394 100644 --- a/src/pandapipes/networks/simple_water_networks.py +++ b/src/pandapipes/networks/simple_water_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/__init__.py b/src/pandapipes/plotting/__init__.py index 2eb4217ad..e37afd30a 100644 --- a/src/pandapipes/plotting/__init__.py +++ b/src/pandapipes/plotting/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index dccea2017..144b64d63 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/geo.py b/src/pandapipes/plotting/geo.py index 2c03da5f9..a3c63c427 100644 --- a/src/pandapipes/plotting/geo.py +++ b/src/pandapipes/plotting/geo.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py index e8b8b5b44..23b5817ec 100644 --- a/src/pandapipes/plotting/plotting_toolbox.py +++ b/src/pandapipes/plotting/plotting_toolbox.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/plotting/simple_plot.py b/src/pandapipes/plotting/simple_plot.py index 2dac028f8..1d0902369 100644 --- a/src/pandapipes/plotting/simple_plot.py +++ b/src/pandapipes/plotting/simple_plot.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/properties/fluids.py b/src/pandapipes/properties/fluids.py index 7917b2e1d..763d7c22d 100644 --- a/src/pandapipes/properties/fluids.py +++ b/src/pandapipes/properties/fluids.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/std_types/__init__.py b/src/pandapipes/std_types/__init__.py index 78defc350..2eb6cdd26 100644 --- a/src/pandapipes/std_types/__init__.py +++ b/src/pandapipes/std_types/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/std_types/std_type_class.py b/src/pandapipes/std_types/std_type_class.py index 28c50857b..b503d369c 100644 --- a/src/pandapipes/std_types/std_type_class.py +++ b/src/pandapipes/std_types/std_type_class.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/std_types/std_types.py b/src/pandapipes/std_types/std_types.py index 9105126b3..d644db02a 100644 --- a/src/pandapipes/std_types/std_types.py +++ b/src/pandapipes/std_types/std_types.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/release_cycle/release_control_test_network.py b/src/pandapipes/test/api/release_cycle/release_control_test_network.py index 65e5b6816..148aaaec4 100644 --- a/src/pandapipes/test/api/release_cycle/release_control_test_network.py +++ b/src/pandapipes/test/api/release_cycle/release_control_test_network.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/__init__.py b/src/pandapipes/test/api/test_components/__init__.py index fe22a75dc..ff738bbca 100644 --- a/src/pandapipes/test/api/test_components/__init__.py +++ b/src/pandapipes/test/api/test_components/__init__.py @@ -1,3 +1,3 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index 0d643e685..3ade57c4e 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index 349a7bc6c..9e9cdbe6b 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 os diff --git a/src/pandapipes/test/api/test_components/test_compressor.py b/src/pandapipes/test/api/test_components/test_compressor.py index 6d6407162..791422022 100644 --- a/src/pandapipes/test/api/test_components/test_compressor.py +++ b/src/pandapipes/test/api/test_components/test_compressor.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index d6945dd55..fa39eb0e3 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index 5bb932be2..08d946778 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 os diff --git a/src/pandapipes/test/api/test_components/test_mass_storage.py b/src/pandapipes/test/api/test_components/test_mass_storage.py index 29789e8ca..9b8707702 100644 --- a/src/pandapipes/test/api/test_components/test_mass_storage.py +++ b/src/pandapipes/test/api/test_components/test_mass_storage.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_pipe_results.py b/src/pandapipes/test/api/test_components/test_pipe_results.py index bf58d84bc..6ba8d0cb6 100644 --- a/src/pandapipes/test/api/test_components/test_pipe_results.py +++ b/src/pandapipes/test/api/test_components/test_pipe_results.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 diff --git a/src/pandapipes/test/api/test_components/test_pressure_control.py b/src/pandapipes/test/api/test_components/test_pressure_control.py index e770716fb..e1fa1835f 100644 --- a/src/pandapipes/test/api/test_components/test_pressure_control.py +++ b/src/pandapipes/test/api/test_components/test_pressure_control.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 by Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. diff --git a/src/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py index 0cf9ce61c..bd974e5a2 100644 --- a/src/pandapipes/test/api/test_components/test_pump.py +++ b/src/pandapipes/test/api/test_components/test_pump.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/test/api/test_components/test_valve.py b/src/pandapipes/test/api/test_components/test_valve.py index dbd737652..bef0df3ae 100644 --- a/src/pandapipes/test/api/test_components/test_valve.py +++ b/src/pandapipes/test/api/test_components/test_valve.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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 os diff --git a/src/pandapipes/test/converter/test_stanet_converter.py b/src/pandapipes/test/converter/test_stanet_converter.py index 2d713b448..83bd32d54 100644 --- a/src/pandapipes/test/converter/test_stanet_converter.py +++ b/src/pandapipes/test/converter/test_stanet_converter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/topology/__init__.py b/src/pandapipes/topology/__init__.py index ad6a36ed9..7942e6754 100644 --- a/src/pandapipes/topology/__init__.py +++ b/src/pandapipes/topology/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/topology/create_graph.py b/src/pandapipes/topology/create_graph.py index 96b0a3132..4741aa916 100644 --- a/src/pandapipes/topology/create_graph.py +++ b/src/pandapipes/topology/create_graph.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. diff --git a/src/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py index 2d5fdbccd..ac06a73bc 100644 --- a/src/pandapipes/topology/graph_searches.py +++ b/src/pandapipes/topology/graph_searches.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics +# Copyright (c) 2020-2024 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. From 69e2ad5b4f0b39047713e5986e93a19e352ae22b Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:06:27 +0100 Subject: [PATCH 059/237] removing init from converter folder --- src/pandapipes/converter/__init__.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/pandapipes/converter/__init__.py diff --git a/src/pandapipes/converter/__init__.py b/src/pandapipes/converter/__init__.py deleted file mode 100644 index 88d36891d..000000000 --- a/src/pandapipes/converter/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020-2024 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. - -from pandapipes.converter.stanet.stanet2pandapipes import stanet_to_pandapipes From a57fa81315fd516331c89c29ff27df464d19037b Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:06:37 +0100 Subject: [PATCH 060/237] adapting CHANGELOG.rst --- CHANGELOG.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index de161c8fc..1638b2f37 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,14 +6,25 @@ Change Log - [ADDED] multiple creation of heat exchanger - [ADDED] support Python 3.11 (now included in test pipeline) - [ADDED] after the connectivity check, intercept the pipeflow if no more nodes are in-service (heat and hydraulic) +- [ADDED] adding biomethane (pure and treated) as additonal fluid +- [ADDED] results tables can be assembled modularly - [CHANGED] dropped support for Python 3.7 (no longer included in test pipeline) - [CHANGED] connectivity check now separated by hydraulics and heat_transfer calculation, so that also results can differ in some rows (NaN or not) - [CHANGED] dynamic creation of lookups for getting pit as pandas tables - [CHANGED] components can have their own internal arrays for specific calculations (e.g. for compressor pressure ratio), so that the pit does not need to include such component specific entries - [CHANGED] .readthedocs.yml due to deprecation - [CHANGED] changing from setuptools flat-layout into src-layout +- [CHANGED] calculate thermal derivative globally, adaptions before/after can be done component-wise +- [CHANGED] moving PipeflowNotConverged error from pipeflow to pipeflow_setup +- [CHANGED] moving 'result_extraction' under pf folder - [FIXED] in STANET converter: bug fix for heat exchanger creation and external temperatures of pipes added +- [FIXED] build igraph considers all components +- [FIXED] creating nxgraph and considering pressure circulation pumps +- [FIXED] error in tutorial 'circular flow in a district heating grid' +- [FIXED] caused error during 'pip install pandapipes' - [REMOVED] broken travis badge removed from readme +- [REMOVED] branch TINIT removed as it is not a solution variable, temperature determined on the fly +- [REMOVED] 'converged' setting from options [0.8.5] - 2023-06-19 ------------------------------- From 941f1a5ce35f0b2b41bf3de7d8c35352ac7da540 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:21:23 +0100 Subject: [PATCH 061/237] small adaptions CHANGELOG.rst --- CHANGELOG.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1638b2f37..739eb92fc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Change Log - [ADDED] support Python 3.11 (now included in test pipeline) - [ADDED] after the connectivity check, intercept the pipeflow if no more nodes are in-service (heat and hydraulic) - [ADDED] adding biomethane (pure and treated) as additonal fluid -- [ADDED] results tables can be assembled modularly +- [ADDED] result tables can be assembled modularly - [CHANGED] dropped support for Python 3.7 (no longer included in test pipeline) - [CHANGED] connectivity check now separated by hydraulics and heat_transfer calculation, so that also results can differ in some rows (NaN or not) - [CHANGED] dynamic creation of lookups for getting pit as pandas tables @@ -15,11 +15,11 @@ Change Log - [CHANGED] .readthedocs.yml due to deprecation - [CHANGED] changing from setuptools flat-layout into src-layout - [CHANGED] calculate thermal derivative globally, adaptions before/after can be done component-wise -- [CHANGED] moving PipeflowNotConverged error from pipeflow to pipeflow_setup +- [CHANGED] moving 'PipeflowNotConverged' error from pipeflow to pipeflow_setup - [CHANGED] moving 'result_extraction' under pf folder - [FIXED] in STANET converter: bug fix for heat exchanger creation and external temperatures of pipes added - [FIXED] build igraph considers all components -- [FIXED] creating nxgraph and considering pressure circulation pumps +- [FIXED] creating nxgraph and considering pressure circulation pumps correctly - [FIXED] error in tutorial 'circular flow in a district heating grid' - [FIXED] caused error during 'pip install pandapipes' - [REMOVED] broken travis badge removed from readme From 201f966d955cede2b9b63962e104e712a919c6c7 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:32:50 +0100 Subject: [PATCH 062/237] changing tag in doc conf --- doc/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index f838d1fe1..f534b111f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -47,9 +47,9 @@ # built documents. # # The short X.Y version. -version = "0.8" +version = "0.9" # The full version, including alpha/beta/rc tags. -release = "0.8.5" +release = "0.9.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 40d85789004004bae491e9c95252060577ba3d1b Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:33:05 +0100 Subject: [PATCH 063/237] changing pandapower dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d30060da5..cad8d74c7 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ long_description_content_type='text/x-rst', url='http://www.pandapipes.org', license='BSD', - install_requires=["pandapower>=2.11.1", "matplotlib", "shapely"], + install_requires=["pandapower>=2.13.1", "matplotlib", "shapely"], extras_require={"docs": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex"], "plotting": ["plotly", "igraph"], "test": ["pytest", "pytest-xdist", "nbmake"], From fcb97acbdedab9872b42b35331fc7d62d9b25740 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Thu, 21 Dec 2023 14:33:31 +0100 Subject: [PATCH 064/237] adding example grids water and gas 0.9.0 --- .../api/old_versions/example_0.9.0_gas.json | 458 +++++++++++++++ .../api/old_versions/example_0.9.0_water.json | 520 ++++++++++++++++++ 2 files changed, 978 insertions(+) create mode 100644 src/pandapipes/test/api/old_versions/example_0.9.0_gas.json create mode 100644 src/pandapipes/test/api/old_versions/example_0.9.0_water.json diff --git a/src/pandapipes/test/api/old_versions/example_0.9.0_gas.json b/src/pandapipes/test/api/old_versions/example_0.9.0_gas.json new file mode 100644 index 000000000..041871129 --- /dev/null +++ b/src/pandapipes/test/api/old_versions/example_0.9.0_gas.json @@ -0,0 +1,458 @@ +{ + "_module": "pandapipes.pandapipes_net", + "_class": "pandapipesNet", + "_object": { + "fluid": { + "_module": "pandapipes.properties.fluids", + "_class": "Fluid", + "_object": "{\"name\": \"hgas\", \"fluid_type\": \"gas\", \"is_gas\": true, \"all_properties\": {\"density\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.7614762591064257}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.733332277439119}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.7072104923835694}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6828947600611692}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.660205611537355}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6389854855679075}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6190946329317856}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6004074588524487}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"viscosity\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0047118361853041e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.04021750220461e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0704866480048474e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.1007402297863992e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.1337005139349375e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.170765177634217e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.2010332619395079e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.231274052527204e-05}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"heat_capacity\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2111.7430409177705}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2129.19525821288}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2148.5756908384515}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2169.8204812997346}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2192.8111461983763}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2217.455354914997}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2243.67904088272}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2271.295613279192}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"molar_mass\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 16.604497, \\\"warn_dependent_variables\\\": false}\"}, \"der_compressibility\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": -0.0022, \\\"warn_dependent_variables\\\": false}\"}, \"compressibility\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyLinear\", \"_object\": \"{\\\"slope\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": -0.0022}, \\\"offset\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0}}\"}, \"lhv\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 13.20179, \\\"warn_dependent_variables\\\": false}\"}, \"hhv\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 14.62197, \\\"warn_dependent_variables\\\": false}\"}}}" + }, + "converged": true, + "name": "net", + "version": "0.9.0", + "format_version": "0.8.0", + "component_list": [ + { + "_module": "pandapipes.component_models.junction_component", + "_class": "Junction", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.pipe_component", + "_class": "Pipe", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.ext_grid_component", + "_class": "ExtGrid", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.sink_component", + "_class": "Sink", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.source_component", + "_class": "Source", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.mass_storage_component", + "_class": "MassStorage", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.valve_component", + "_class": "Valve", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.flow_control_component", + "_class": "FlowControlComponent", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.pressure_control_component", + "_class": "PressureControlComponent", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.compressor_component", + "_class": "Compressor", + "_object": "{}" + } + ], + "junction": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"pn_bar\",\"tfluid_k\",\"height_m\",\"in_service\",\"type\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12],\"data\":[[\"Junction 0\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 1\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 2\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 3\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 4\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 5\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 6\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 7\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 8\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 9\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 10\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 11\",0.7,283.0,0.0,true,\"junction\"],[\"Junction 12\",0.7,283.0,0.0,true,\"junction\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "pn_bar": "float64", + "tfluid_k": "float64", + "height_m": "float64", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "junction_geodata": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"x\",\"y\"],\"index\":[],\"data\":[]}", + "orient": "split", + "dtype": { + "x": "float64", + "y": "float64" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "pipe": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"from_junction\",\"to_junction\",\"std_type\",\"length_km\",\"diameter_m\",\"k_mm\",\"loss_coefficient\",\"alpha_w_per_m2k\",\"text_k\",\"qext_w\",\"sections\",\"in_service\",\"type\"],\"index\":[0,1,2,3,4,5,6,7],\"data\":[[\"Pipe 0\",0,1,null,3.0,0.1,1.0,0.0,10.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 1\",2,3,null,6.0,0.075,0.1,0.0,3.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 2\",3,4,null,5.0,0.06,0.1,0.0,20.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 3\",4,5,null,0.1,0.07,0.1,0.0,2.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 4\",5,6,null,4.5,0.085,0.1,0.0,2.5,293.0,0.0,10,true,\"pipe\"],[\"Pipe 5\",8,7,null,4.0,0.03,0.1,0.0,1.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 6\",9,10,null,1.0,0.03,0.1,0.0,1.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 7\",11,12,null,1.5,0.09,0.1,0.0,3.0,293.0,0.0,10,true,\"pipe\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "from_junction": "uint32", + "to_junction": "uint32", + "std_type": "object", + "length_km": "float64", + "diameter_m": "float64", + "k_mm": "float64", + "loss_coefficient": "float64", + "alpha_w_per_m2k": "float64", + "text_k": "float64", + "qext_w": "float64", + "sections": "uint32", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "pipe_geodata": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"coords\"],\"index\":[],\"data\":[]}", + "orient": "split", + "dtype": { + "coords": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "ext_grid": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"junction\",\"p_bar\",\"t_k\",\"in_service\",\"type\"],\"index\":[0,1],\"data\":[[\"External Grid 0\",0,16.0,280.0,true,\"pt\"],[\"External Grid 1\",8,15.0,285.0,true,\"pt\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "junction": "uint32", + "p_bar": "float64", + "t_k": "float64", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "controller": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"object\",\"in_service\",\"order\",\"level\",\"initial_run\",\"recycle\"],\"index\":[0,1],\"data\":[[{\"_module\":\"pandapower.control.controller.const_control\",\"_class\":\"ConstControl\",\"_object\":\"{\\\"index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, \\\"matching_params\\\": {\\\"element\\\": \\\"sink\\\", \\\"variable\\\": \\\"mdot_kg_per_s\\\", \\\"element_index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 1}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 2}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 3}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 4}], \\\"dtype\\\": \\\"int64\\\"}}, \\\"data_source\\\": {\\\"_module\\\": \\\"pandapower.timeseries.data_sources.frame_data\\\", \\\"_class\\\": \\\"DFData\\\", \\\"_object\\\": \\\"{\\\\\\\"df\\\\\\\": {\\\\\\\"_module\\\\\\\": \\\\\\\"pandas.core.frame\\\\\\\", \\\\\\\"_class\\\\\\\": \\\\\\\"DataFrame\\\\\\\", \\\\\\\"_object\\\\\\\": \\\\\\\"{\\\\\\\\\\\\\\\"columns\\\\\\\\\\\\\\\":[\\\\\\\\\\\\\\\"0\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"1\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"2\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"3\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"4\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"5\\\\\\\\\\\\\\\"],\\\\\\\\\\\\\\\"index\\\\\\\\\\\\\\\":[0,1,2,3],\\\\\\\\\\\\\\\"data\\\\\\\\\\\\\\\":[[0.2,0.1,0.5,0.07,0.09,0.1],[0.3,0.2,0.6,0.08,0.1,0.2],[0.4,0.3,0.7,0.09,0.11,0.3],[0.5,0.4,0.8,0.1,0.12,0.4]]}\\\\\\\", \\\\\\\"orient\\\\\\\": \\\\\\\"split\\\\\\\", \\\\\\\"dtype\\\\\\\": {\\\\\\\"0\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"1\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"2\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"3\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"4\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"5\\\\\\\": \\\\\\\"float64\\\\\\\"}, \\\\\\\"is_multiindex\\\\\\\": false, \\\\\\\"is_multicolumn\\\\\\\": false}}\\\"}, \\\"element_index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 1}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 2}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 3}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 4}], \\\"dtype\\\": \\\"int64\\\"}, \\\"element\\\": \\\"sink\\\", \\\"values\\\": null, \\\"profile_name\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [\\\"0\\\", \\\"1\\\", \\\"2\\\", \\\"3\\\", \\\"4\\\"], \\\"dtype\\\": \\\" Date: Fri, 22 Dec 2023 08:47:37 +0100 Subject: [PATCH 065/237] bug in release yml fixed --- .github/workflows/release.yml | 3 ++- setup.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a583ac9a5..71bafbf41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,7 +86,8 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install pytest igraph pytest-split - if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + shell: bash - name: Install pandapipes from TestPyPI if: ${{ inputs.upload_server == 'testpypi'}} run: | diff --git a/setup.py b/setup.py index cad8d74c7..655a81bd9 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( name='pandapipes', - version='0.9.0', + version='0.9.0.post1', author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' 'jolando.kisse@uni-kassel.de', From f2470a401df078569001ffd24da10d8e4c55374f Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 22 Dec 2023 08:53:36 +0100 Subject: [PATCH 066/237] test windows and ubuntu --- .github/workflows/run_tests_develop.yml | 23 ++++++++++++++--------- .github/workflows/run_tests_master.yml | 20 ++++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index b0bcb60e2..6949d5abe 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -14,11 +14,12 @@ on: jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -29,7 +30,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install pytest igraph pytest-split - if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . @@ -52,12 +53,12 @@ jobs: verbose: true linting: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.10'] - + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -84,10 +85,12 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics tutorial_tests: - runs-on: ubuntu-latest + #runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -98,7 +101,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install pytest nbmake pytest-xdist pytest-split igraph - if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . @@ -110,10 +113,12 @@ jobs: python -m pytest --nbmake -n=auto "./tutorials" docs_check: - runs-on: ubuntu-latest + #runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: python-version: [ '3.10' ] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 153a78694..64d530524 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -# pandapipes-master branch has to work with pandapower-master branch +# pandapipes-master branch is designed to work with pandapower-master branch name: ppipes_master @@ -13,12 +13,12 @@ on: jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] - + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -29,7 +29,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install pytest igraph pytest-split - if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; python -m pip install . @@ -52,10 +52,12 @@ jobs: verbose: true tutorial_tests: - runs-on: ubuntu-latest + #runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -66,7 +68,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install pytest nbmake pytest-xdist pytest-split igraph - if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower python -m pip install . @@ -78,10 +80,12 @@ jobs: python -m pytest --nbmake -n=auto "./tutorials" docs_check: - runs-on: ubuntu-latest + #runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: python-version: [ '3.10' ] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 4663e83284e52dc4866c2dced44218f0ee383548 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 22 Dec 2023 08:58:03 +0100 Subject: [PATCH 067/237] test windows and ubuntu --- .github/workflows/run_tests_develop.yml | 7 ++++--- .github/workflows/run_tests_master.yml | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 6949d5abe..1cd5d011a 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -34,6 +34,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . + shell: bash - name: List all installed packages run: | python -m pip list @@ -72,6 +73,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . + shell: bash - name: List all installed packages run: | python -m pip list @@ -105,6 +107,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . + shell: bash - name: List all installed packages run: | python -m pip list @@ -113,12 +116,10 @@ jobs: python -m pytest --nbmake -n=auto "./tutorials" docs_check: - #runs-on: ubuntu-latest - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: matrix: python-version: [ '3.10' ] - os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 64d530524..ccdb20c8b 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -80,12 +80,10 @@ jobs: python -m pytest --nbmake -n=auto "./tutorials" docs_check: - #runs-on: ubuntu-latest - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: matrix: python-version: [ '3.10' ] - os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From b1c734c7aefe86e139ec24865ffe5c4104cc1f2c Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 22 Dec 2023 09:11:53 +0100 Subject: [PATCH 068/237] remove comments add shell --- .github/workflows/run_tests_develop.yml | 3 --- .github/workflows/run_tests_master.yml | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 1cd5d011a..acf46022d 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -15,7 +15,6 @@ on: jobs: build: runs-on: ${{ matrix.os }} - #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] @@ -55,7 +54,6 @@ jobs: linting: runs-on: ${{ matrix.os }} - #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.10'] @@ -87,7 +85,6 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics tutorial_tests: - #runs-on: ubuntu-latest runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index ccdb20c8b..9be8fe64f 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -14,7 +14,6 @@ on: jobs: build: runs-on: ${{ matrix.os }} - #runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] @@ -33,6 +32,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; python -m pip install . + shell: bash - name: List all installed packages run: | python -m pip list @@ -52,7 +52,6 @@ jobs: verbose: true tutorial_tests: - #runs-on: ubuntu-latest runs-on: ${{ matrix.os }} strategy: matrix: @@ -72,6 +71,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower python -m pip install . + shell: bash - name: List all installed packages run: | python -m pip list From 9ee1336f023055718111b07213ebaae9ca43fe91 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Fri, 22 Dec 2023 09:36:45 +0100 Subject: [PATCH 069/237] remove post1 from version tag --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 655a81bd9..cad8d74c7 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( name='pandapipes', - version='0.9.0.post1', + version='0.9.0', author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' 'jolando.kisse@uni-kassel.de', From 2d6d1a6771c9422c43c91503d4ee5148d0128764 Mon Sep 17 00:00:00 2001 From: sdrauz Date: Tue, 9 Jan 2024 10:49:14 +0100 Subject: [PATCH 070/237] description-file is deprecated. Renamed it to description_file. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1e9a70787..7c504ed00 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [metadata] -description-file = installation.rst +description_file = installation.rst license_file = LICENSE From 3a158345be0f7e5ce9aaa9723e654897e3eb7de5 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 16 Jan 2024 12:45:45 +0100 Subject: [PATCH 071/237] Added unsupplied_junctions and elements_on_path to pandapipes --- .../test/topology/test_graph_searches.py | 23 ++++++ src/pandapipes/topology/__init__.py | 1 + src/pandapipes/topology/graph_searches.py | 74 +++++++++++++++++++ src/pandapipes/topology/topology_toolbox.py | 42 +++++++++++ 4 files changed, 140 insertions(+) create mode 100644 src/pandapipes/topology/topology_toolbox.py diff --git a/src/pandapipes/test/topology/test_graph_searches.py b/src/pandapipes/test/topology/test_graph_searches.py index 404e5c889..d9d2c0edc 100644 --- a/src/pandapipes/test/topology/test_graph_searches.py +++ b/src/pandapipes/test/topology/test_graph_searches.py @@ -4,6 +4,8 @@ import pandapipes.networks as nw import pandapipes.topology as top +import networkx as nx +import pytest def test_connected_components(): @@ -18,3 +20,24 @@ def test_connected_components(): assert len(list(top.connected_components(mg))) == 6 mg = top.create_nxgraph(net, include_pipes=False, include_valves=False) assert len(list(top.connected_components(mg))) == 8 + + +def test_unsupplied_buses_with_in_service(): + net = nw.gas_versatility() + assert top.unsupplied_junctions(net) == set() + net.pipe.loc[7, "in_service"] = False + assert top.unsupplied_junctions(net) == {8} + + +def test_elements_on_path(): + net = nw.gas_versatility() + for multi in [True, False]: + mg = top.create_nxgraph(net, multi=multi) + path = nx.shortest_path(mg, 0, 6) + assert top.elements_on_path(mg, path, "pipe") == [0, 9] + assert top.elements_on_path(mg, path) == [0, 9] + assert top.elements_on_path(mg, path, "valve") == [] + assert top.elements_on_path(mg, path, "pump") == [0] + with pytest.raises(ValueError) as exception_info: + top.elements_on_path(mg, path, element="source") + assert str(exception_info.value) == "Invalid element type source" diff --git a/src/pandapipes/topology/__init__.py b/src/pandapipes/topology/__init__.py index 7942e6754..4bc880a8b 100644 --- a/src/pandapipes/topology/__init__.py +++ b/src/pandapipes/topology/__init__.py @@ -3,5 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. from pandapipes.topology.create_graph import * +from pandapipes.topology.topology_toolbox import * from pandapipes.topology.graph_searches import * from pandapower.topology.graph_searches import connected_component, connected_components diff --git a/src/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py index ac06a73bc..89e063e26 100644 --- a/src/pandapipes/topology/graph_searches.py +++ b/src/pandapipes/topology/graph_searches.py @@ -5,6 +5,7 @@ import networkx as nx import pandas as pd from pandapipes.topology.create_graph import create_nxgraph +from pandapipes.topology.topology_toolbox import get_all_branch_component_table_names def calc_distance_to_junction(net, junction, notravjunctions=None, nogojunctions=None, @@ -78,6 +79,79 @@ def calc_minimum_distance_to_junctions(net, junctions, notravjunctions=None, nog return pd.Series(nx.single_source_dijkstra_path_length(mg, junction)) +def unsupplied_junctions(net, mg=None, slacks=None, respect_valves=True): + """ + Finds junctions, that are not connected to an external grid. + + INPUT: + **net** (pandapipesNet) - variable that contains a pandapipes network + + OPTIONAL: + **mg** (NetworkX graph) - NetworkX Graph or MultiGraph that represents a pandapipes network. + + **in_service_only** (boolean, False) - Defines whether only in service junctions should be + included in unsupplied_junctions. + + **slacks** (set, None) - junctions which are considered as root / slack junctions. If None, all + existing slack junctions are considered. + + **respect_valves** (boolean, True) - Fixes how to consider valves - only in case of no + given mg. + + OUTPUT: + **uj** (set) - unsupplied junctions + + EXAMPLE: + import pandapipes.topology as top + + top.unsupplied_junctions(net) + """ + + mg = mg or create_nxgraph(net, respect_status_valves=respect_valves) + if slacks is None: + slacks = set(net.ext_grid[net.ext_grid.in_service].junction.values) + not_supplied = set() + for cc in nx.connected_components(mg): + if not set(cc) & slacks: + not_supplied.update(set(cc)) + return not_supplied + + +def elements_on_path(mg, path, element="pipe"): + """ + Finds all elements that connect a given path of junctions. + + INPUT: + **mg** (NetworkX graph) - NetworkX Graph or MultiGraph that represents a pandapipes network. + + **path** (list) - List of connected junctions. + + **element** (string, "l") - element type of type BranchComponent + + **multi** (boolean, True) - True: Applied on a NetworkX MultiGraph + False: Applied on a NetworkX Graph + + OUTPUT: + **elements** (list) - Returns a list of all elements on the path. + + EXAMPLE: + import topology as top + + mg = top.create_nxgraph(net) + elements = top.elements_on_path(mg, [4, 5, 6]) + + """ + table_names = get_all_branch_component_table_names() + if element not in table_names: + raise ValueError("Invalid element type %s" % element) + if isinstance(mg, nx.MultiGraph): + return [edge[1] for b1, b2 in zip(path, path[1:]) for edge in mg.get_edge_data(b1, b2).keys() + if edge[0] == element] + else: + return [mg.get_edge_data(b1, b2)["key"][1] for b1, b2 in zip(path, path[1:]) + if mg.get_edge_data(b1, b2)["key"][0] == element] + + if __name__ == '__main__': import pandapipes.networks as nw net = nw.gas_meshed_delta() diff --git a/src/pandapipes/topology/topology_toolbox.py b/src/pandapipes/topology/topology_toolbox.py new file mode 100644 index 000000000..e1b754822 --- /dev/null +++ b/src/pandapipes/topology/topology_toolbox.py @@ -0,0 +1,42 @@ +# Copyright (c) 2020-2024 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. + +from pandapipes.component_models.abstract_models.branch_models import BranchComponent + + +def get_all_branch_component_models(): + """ + Get all models of available branch components + + :return: branch model + :rtype: list + """ + def get_all_subclasses(cls): + all_subclasses = list() + for subclass in cls.__subclasses__(): + all_subclasses.append(subclass) + all_subclasses.extend(get_all_subclasses(subclass)) + return all_subclasses + + all_branch_components = get_all_subclasses(BranchComponent) + filtered = list() + for bc in all_branch_components: + try: + bc.table_name() + filtered.append(bc) + except Exception as e: + # component does not have a table_name implemented + continue + return filtered + + +def get_all_branch_component_table_names(): + """ + Get all table names of available branch components + + :return: table names + :rtype: list + """ + cm = get_all_branch_component_models() + return [c.table_name() for c in cm] From c3eb8bd48336ff4f0ed86dd127567c2efe58b46e Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 16 Jan 2024 13:05:43 +0100 Subject: [PATCH 072/237] added logging info for branch components with no table name --- src/pandapipes/topology/topology_toolbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/topology/topology_toolbox.py b/src/pandapipes/topology/topology_toolbox.py index e1b754822..0b2df87c2 100644 --- a/src/pandapipes/topology/topology_toolbox.py +++ b/src/pandapipes/topology/topology_toolbox.py @@ -3,6 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. from pandapipes.component_models.abstract_models.branch_models import BranchComponent +import logging def get_all_branch_component_models(): @@ -26,8 +27,7 @@ def get_all_subclasses(cls): bc.table_name() filtered.append(bc) except Exception as e: - # component does not have a table_name implemented - continue + logging.info(f"branch component {bc} has no table name {e}") return filtered From 29d6073c949805af255f458a0be7a6e8fd329520 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 20 Feb 2024 10:17:45 +0100 Subject: [PATCH 073/237] fixed error for setting output pressure in case of oos circulation pumps --- .../component_models/abstract_models/circulation_pump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/component_models/abstract_models/circulation_pump.py b/src/pandapipes/component_models/abstract_models/circulation_pump.py index dd18a9b6f..c678b44a2 100644 --- a/src/pandapipes/component_models/abstract_models/circulation_pump.py +++ b/src/pandapipes/component_models/abstract_models/circulation_pump.py @@ -68,7 +68,7 @@ def create_pit_node_entries(cls, net, node_pit): """ circ_pump_tbl = net[cls.table_name()][net[cls.table_name()][cls.active_identifier()].values] - junction = net[cls.table_name()][cls.from_to_node_cols()[1]].values + junction = circ_pump_tbl[cls.from_to_node_cols()[1]].values # TODO: there should be a warning, if any p_bar value is not given or any of the types does # not contain "p", as this should not be allowed for this component From d4ccb1b8efaa11bd2b9e0d12bae132be85263af4 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 20 Feb 2024 22:00:36 +0100 Subject: [PATCH 074/237] added bulk function for creating heat consumers --- src/pandapipes/create.py | 80 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 7c466e132..bfd3f801f 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1651,10 +1651,10 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w :param net: The net for which the heat exchangers should be created :type net: pandapipesNet - :param from_junctions: ID of the junctions on one side the heat exchangers will be\ + :param from_junctions: IDs of the junctions on one side the heat exchangers will be\ connected with :type from_junctions: Iterable(int) - :param to_junctions: ID of the junctions on the other side the heat exchangers will be\ + :param to_junctions: IDs of the junctions on the other side the heat exchangers will be\ connected with :type to_junctions: Iterable(int) :param diameter_m: The heat exchangers inner diameter in [m] @@ -1665,9 +1665,10 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w :param loss_coefficient: An additional pressure loss coefficient, introduced by e.g. bends :type loss_coefficient: Iterable(float) or float :param name: The name of the heat exchangers - :type name: str, default None - :param index: Force a specified ID if it is available. If None, the index one higher than the\ - highest already existing index is selected. + :type name: Iterable(str) or str, default None + :param index: Force specified IDs if they are available. If None, the index one higher than the\ + highest already existing index is selected and counted onwards for the amount of heat \ + exchangers created. :type index: Iterable(str) or str, default None :param in_service: True if the heat exchangers are in service or False if they are out of service :type in_service: Iterable(bool) or bool, default True @@ -1695,6 +1696,75 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w return index +def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, + controlled_mdot_kg_per_s=None, qext_w=None, deltat_k=None, treturn_k=None, + name=None, index=None, in_service=True, type="heat_consumer", **kwargs): + """ + Creates several heat consumer elements in net["heat_consumer"] from heat consumer parameters. + + :param net: The net for which this heat consumer should be created + :type net: + :param from_junctions: IDs of the junctions on one side which the heat consumers will be \ + connected with + :type from_junctions: Iterable(int) + :param to_junctions: IDs of the junctions on the other side which the heat consumers will be \ + connected with + :type to_junctions: Iterable(int) + :param diameter_m: The heat consumers' inner diameter in [m] - only for result calculation + :type diameter_m: Iterable(float) or float + :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. + :type controlled_mdot_kg_per_s: Iterable(float) or float, default None + :param qext_w: External heat flux in [W]. If positive, heat is extracted from the network. If \ + negative, heat is being fed into the network from a heat source. + :type qext_w: Iterable(float) or float, default None + :param deltat_k: Temperature difference set point between flow and return in [K]. + :type deltat_k: Iterable(float) or float, default None + :param treturn_k: Return temperature set point in [K]. + :type treturn_k: Iterable(float) or float, default None + :param name: Names of the heat consumer elements + :type name: Iterable(str) or str, default None + :param index: Force specified IDs if they are available. If None, the index one higher than the\ + highest already existing index is selected and counted onwards for the amount of heat \ + consumers created. + :type index: Iterable(int) or int, default None + :param in_service: True for heat consumers that are in service, False for those out of service + :type in_service: Iterable(bool) or bool, default True + :param type: Currently not used - possibility to specify certain types of heat consumers + :type type: Iterable(str) or str, default "heat_consumer" + :param kwargs: Additional keyword arguments will be added as further columns to the \ + net["heat_consumer"] table + :type kwargs: dict + :return: index - The unique IDs of the created heat consumers + :rtype: int + + :Example: + >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, qext_w=2000) + """ + # TODO: change this to vectorized form + if deltat_k is not None or treturn_k is not None: + raise NotImplementedError("The models for consumers with fixed temperature difference or " + "fixed return temperature are not implemented yet.") + if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) + + (treturn_k is None) !=2): + raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") + if deltat_k is not None and treturn_k is not None: + raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " + r"flow temperature is independent of the heat consumer model.") + + add_new_component(net, HeatConsumer) + + index = _get_multiple_index_with_check(net, "heat_consumer", index, len(from_junctions)) + _check_branches(net, from_junctions, to_junctions, "heat_consumer") + + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, + "diameter_m": diameter_m, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, + "qext_w": qext_w, "deltat_k": deltat_k, "treturn_k": treturn_k, + "in_service": bool(in_service), "type": type} + _set_multiple_entries(net, "heat_consumer", index, **entries, **kwargs) + return index + + def create_fluid_from_lib(net, name, overwrite=True): """ Creates a fluid from library (if there is an entry) and sets net["fluid"] to this value. From 9427b6aed005f0a318356aada64971edc0dc4455 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 11:54:55 +0100 Subject: [PATCH 075/237] moved test data --- src/pandapipes/test/__init__.py | 1 + .../{pipeflow_internals => }/data/Temperature_2zu_2ab_an.csv | 0 .../data/Temperature_masche_1load_an.csv | 0 .../data/Temperature_masche_1load_direction_an.csv | 0 .../{pipeflow_internals => }/data/Temperature_one_pipe_an.csv | 0 .../data/Temperature_tee_2ab_1zu_an.csv | 0 .../data/Temperature_tee_2zu_1ab_an.csv | 0 .../test/{pipeflow_internals => }/data/ext_grid_p.csv | 0 .../test/{pipeflow_internals => }/data/gas_sections_an.csv | 0 .../test/{pipeflow_internals => }/data/heat_exchanger_test.csv | 0 .../test/{pipeflow_internals => }/data/hydraulics.csv | 0 .../data/pressure_control_test_analytical.csv | 0 .../test/{pipeflow_internals => }/data/test_circ_pump_mass.csv | 0 .../{pipeflow_internals => }/data/test_circ_pump_pressure.csv | 0 .../test_time_series_results/res_ext_grid/mdot_kg_per_s.csv | 0 .../data/test_time_series_results/res_junction/p_bar.csv | 0 .../data/test_time_series_results/res_pipe/lambda.csv | 0 .../data/test_time_series_results/res_pipe/reynolds.csv | 0 .../data/test_time_series_results/res_sink/mdot_kg_per_s.csv | 0 .../data/test_time_series_results/res_source/mdot_kg_per_s.csv | 0 .../data/test_time_series_sink_profiles.csv | 0 .../data/test_time_series_source_profiles.csv | 0 src/pandapipes/test/pipeflow_internals/__init__.py | 3 --- 23 files changed, 1 insertion(+), 3 deletions(-) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_2zu_2ab_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_masche_1load_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_masche_1load_direction_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_one_pipe_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_tee_2ab_1zu_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/Temperature_tee_2zu_1ab_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/ext_grid_p.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/gas_sections_an.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/heat_exchanger_test.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/hydraulics.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/pressure_control_test_analytical.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_circ_pump_mass.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_circ_pump_pressure.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_junction/p_bar.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_pipe/lambda.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_pipe/reynolds.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_sink/mdot_kg_per_s.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_results/res_source/mdot_kg_per_s.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_sink_profiles.csv (100%) rename src/pandapipes/test/{pipeflow_internals => }/data/test_time_series_source_profiles.csv (100%) diff --git a/src/pandapipes/test/__init__.py b/src/pandapipes/test/__init__.py index c22811717..3b8e845a2 100644 --- a/src/pandapipes/test/__init__.py +++ b/src/pandapipes/test/__init__.py @@ -6,6 +6,7 @@ from pandapipes import pp_dir test_path = os.path.join(pp_dir, 'test') +data_path = os.path.join(test_path, "data") tutorials_path = os.path.join(os.path.dirname(pp_dir), 'tutorials') from pandapipes.test.run_tests import * from pandapipes.test.test_imports import * diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv b/src/pandapipes/test/data/Temperature_2zu_2ab_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_2zu_2ab_an.csv rename to src/pandapipes/test/data/Temperature_2zu_2ab_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv b/src/pandapipes/test/data/Temperature_masche_1load_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_an.csv rename to src/pandapipes/test/data/Temperature_masche_1load_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv b/src/pandapipes/test/data/Temperature_masche_1load_direction_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_masche_1load_direction_an.csv rename to src/pandapipes/test/data/Temperature_masche_1load_direction_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv b/src/pandapipes/test/data/Temperature_one_pipe_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_one_pipe_an.csv rename to src/pandapipes/test/data/Temperature_one_pipe_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv b/src/pandapipes/test/data/Temperature_tee_2ab_1zu_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2ab_1zu_an.csv rename to src/pandapipes/test/data/Temperature_tee_2ab_1zu_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv b/src/pandapipes/test/data/Temperature_tee_2zu_1ab_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/Temperature_tee_2zu_1ab_an.csv rename to src/pandapipes/test/data/Temperature_tee_2zu_1ab_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/ext_grid_p.csv b/src/pandapipes/test/data/ext_grid_p.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/ext_grid_p.csv rename to src/pandapipes/test/data/ext_grid_p.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/gas_sections_an.csv b/src/pandapipes/test/data/gas_sections_an.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/gas_sections_an.csv rename to src/pandapipes/test/data/gas_sections_an.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv b/src/pandapipes/test/data/heat_exchanger_test.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/heat_exchanger_test.csv rename to src/pandapipes/test/data/heat_exchanger_test.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/hydraulics.csv b/src/pandapipes/test/data/hydraulics.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/hydraulics.csv rename to src/pandapipes/test/data/hydraulics.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv b/src/pandapipes/test/data/pressure_control_test_analytical.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/pressure_control_test_analytical.csv rename to src/pandapipes/test/data/pressure_control_test_analytical.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv b/src/pandapipes/test/data/test_circ_pump_mass.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_circ_pump_mass.csv rename to src/pandapipes/test/data/test_circ_pump_mass.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv b/src/pandapipes/test/data/test_circ_pump_pressure.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_circ_pump_pressure.csv rename to src/pandapipes/test/data/test_circ_pump_pressure.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv b/src/pandapipes/test/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv rename to src/pandapipes/test/data/test_time_series_results/res_ext_grid/mdot_kg_per_s.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv b/src/pandapipes/test/data/test_time_series_results/res_junction/p_bar.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_junction/p_bar.csv rename to src/pandapipes/test/data/test_time_series_results/res_junction/p_bar.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv b/src/pandapipes/test/data/test_time_series_results/res_pipe/lambda.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/lambda.csv rename to src/pandapipes/test/data/test_time_series_results/res_pipe/lambda.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv b/src/pandapipes/test/data/test_time_series_results/res_pipe/reynolds.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/reynolds.csv rename to src/pandapipes/test/data/test_time_series_results/res_pipe/reynolds.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv b/src/pandapipes/test/data/test_time_series_results/res_sink/mdot_kg_per_s.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_sink/mdot_kg_per_s.csv rename to src/pandapipes/test/data/test_time_series_results/res_sink/mdot_kg_per_s.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv b/src/pandapipes/test/data/test_time_series_results/res_source/mdot_kg_per_s.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_source/mdot_kg_per_s.csv rename to src/pandapipes/test/data/test_time_series_results/res_source/mdot_kg_per_s.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv b/src/pandapipes/test/data/test_time_series_sink_profiles.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_sink_profiles.csv rename to src/pandapipes/test/data/test_time_series_sink_profiles.csv diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv b/src/pandapipes/test/data/test_time_series_source_profiles.csv similarity index 100% rename from src/pandapipes/test/pipeflow_internals/data/test_time_series_source_profiles.csv rename to src/pandapipes/test/data/test_time_series_source_profiles.csv diff --git a/src/pandapipes/test/pipeflow_internals/__init__.py b/src/pandapipes/test/pipeflow_internals/__init__.py index 1d23cb89e..d4d84cce8 100644 --- a/src/pandapipes/test/pipeflow_internals/__init__.py +++ b/src/pandapipes/test/pipeflow_internals/__init__.py @@ -2,6 +2,3 @@ # 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 os - -internals_data_path = os.path.join(os.path.dirname(__file__), "data") From 603efc03fc256f2e59dd90d45618aa6e4c46ecb4 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:06:08 +0100 Subject: [PATCH 076/237] - working with mass - properties at norm state --- .../abstract_models/branch_models.py | 4 +- .../branch_w_internals_models.py | 8 +- .../branch_wo_internals_models.py | 7 +- .../component_models/compressor_component.py | 6 +- .../flow_control_component.py | 8 +- .../component_models/junction_component.py | 4 +- .../component_models/pipe_component.py | 17 ++-- .../pressure_control_component.py | 4 +- .../component_models/pump_component.py | 4 +- src/pandapipes/idx_branch.py | 57 ++++++------- src/pandapipes/idx_node.py | 21 +++-- src/pandapipes/pf/build_system_matrix.py | 10 +-- src/pandapipes/pf/derivative_calculation.py | 84 ++++++++++--------- src/pandapipes/pf/pipeflow_setup.py | 11 ++- src/pandapipes/pf/result_extraction.py | 16 ++-- src/pandapipes/pipeflow.py | 38 ++++----- .../properties/properties_toolbox.py | 42 ++++++++++ .../test/api/test_components/test_ext_grid.py | 13 ++- .../test_components/test_pressure_control.py | 2 +- .../test/api/test_components/test_pump.py | 10 +-- .../test/api/test_components/test_valve.py | 2 +- .../test/pipeflow_internals/test_inservice.py | 2 +- .../pipeflow_internals/test_pipeflow_modes.py | 15 ++-- .../pipeflow_internals/test_time_series.py | 9 +- .../test/stanet_comparison/test_gas_stanet.py | 3 +- src/pandapipes/timeseries/run_time_series.py | 6 +- 26 files changed, 213 insertions(+), 190 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index 9516dcbb6..184b98a18 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -5,7 +5,7 @@ import numpy as np from pandapipes.component_models.abstract_models.base_component import Component -from pandapipes.idx_branch import VINIT, branch_cols +from pandapipes.idx_branch import MINIT, branch_cols from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup try: @@ -88,7 +88,7 @@ def create_pit_branch_entries(cls, net, branch_pit): from_nodes = junction_idx_lookup[net[cls.table_name()][fn_col].values] to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) - branch_component_pit[:, VINIT] = 0.1 + branch_component_pit[:, MINIT] = 0.1 return branch_component_pit, node_pit, from_nodes, to_nodes @classmethod diff --git a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py index c21d7d582..a50466352 100644 --- a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py @@ -6,10 +6,9 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent from pandapipes.component_models.component_toolbox import set_entry_check_repeat -from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, RHO, ETA, CP, ELEMENT_IDX, TOUTINIT +from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX from pandapipes.idx_node import L, node_cols, TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number -from pandapipes.properties.fluids import get_fluid try: import pandaplan.core.pplog as logging @@ -197,11 +196,6 @@ def create_pit_branch_entries(cls, net, branch_pit): branch_w_internals_pit[:, FROM_NODE] = from_nodes branch_w_internals_pit[:, TO_NODE] = to_nodes branch_w_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] - tm = (node_pit[from_nodes, TINIT_NODE] + branch_w_internals_pit[:, TOUTINIT]) / 2 - fluid = get_fluid(net) - branch_w_internals_pit[:, RHO] = fluid.get_density(tm) - branch_w_internals_pit[:, ETA] = fluid.get_viscosity(tm) - branch_w_internals_pit[:, CP] = fluid.get_heat_capacity(tm) return branch_w_internals_pit, internal_pipe_number @classmethod diff --git a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py index 1ec2589ab..e57dbb7f5 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py @@ -4,7 +4,7 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent -from pandapipes.idx_branch import FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX, RHO, ETA, CP, ACTIVE +from pandapipes.idx_branch import FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX, ACTIVE from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup @@ -83,11 +83,6 @@ def create_pit_branch_entries(cls, net, branch_pit): branch_wo_internals_pit[:, FROM_NODE] = from_nodes branch_wo_internals_pit[:, TO_NODE] = to_nodes branch_wo_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] - tm = (node_pit[from_nodes, TINIT_NODE] + branch_wo_internals_pit[:, TOUTINIT]) / 2 - fluid = get_fluid(net) - branch_wo_internals_pit[:, RHO] = fluid.get_density(tm) - branch_wo_internals_pit[:, ETA] = fluid.get_viscosity(tm) - branch_wo_internals_pit[:, CP] = fluid.get_heat_capacity(tm) branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values return branch_wo_internals_pit diff --git a/src/pandapipes/component_models/compressor_component.py b/src/pandapipes/component_models/compressor_component.py index a65372d7a..21beca1c3 100644 --- a/src/pandapipes/component_models/compressor_component.py +++ b/src/pandapipes/component_models/compressor_component.py @@ -8,7 +8,7 @@ from pandapipes.component_models.component_toolbox import get_component_array from pandapipes.component_models.junction_component import Junction from pandapipes.component_models.pump_component import Pump -from pandapipes.idx_branch import VINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL +from pandapipes.idx_branch import MINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL from pandapipes.idx_node import PINIT, PAMB @@ -76,8 +76,8 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo p_to_calc = p_from * compressor_array[:, cls.PRESSURE_RATIO] pl_abs = p_to_calc - p_from - v_mps = compressor_branch_pit[:, VINIT] - pl_abs[v_mps < 0] = 0 # force pressure lift = 0 for reverse flow + m_mps = compressor_branch_pit[:, MINIT] + pl_abs[m_mps < 0] = 0 # force pressure lift = 0 for reverse flow compressor_branch_pit[:, PL] = pl_abs diff --git a/src/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py index f4b88388b..66f884b88 100644 --- a/src/pandapipes/component_models/flow_control_component.py +++ b/src/pandapipes/component_models/flow_control_component.py @@ -9,8 +9,7 @@ from pandapipes.component_models.component_toolbox import \ standard_branch_wo_internals_result_lookup, get_component_array from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DV, VINIT, \ - RHO, LOAD_VEC_BRANCHES +from pandapipes.idx_branch import D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MINIT, LOAD_VEC_BRANCHES from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -51,8 +50,7 @@ def create_pit_branch_entries(cls, net, branch_pit): fc_branch_pit = super().create_pit_branch_entries(net, branch_pit) fc_branch_pit[:, D] = net[cls.table_name()].diameter_m.values fc_branch_pit[:, AREA] = fc_branch_pit[:, D] ** 2 * np.pi / 4 - fc_branch_pit[:, VINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values / \ - (fc_branch_pit[:, AREA] * fc_branch_pit[:, RHO]) + fc_branch_pit[:, MINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values @classmethod def create_component_array(cls, net, component_pits): @@ -83,7 +81,7 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo active = fc_array[:, cls.CONTROL_ACTIVE].astype(np.bool_) fc_branch_pit[active, JAC_DERIV_DP] = 0 fc_branch_pit[active, JAC_DERIV_DP1] = 0 - fc_branch_pit[active, JAC_DERIV_DV] = 1 + fc_branch_pit[active, JAC_DERIV_DM] = 1 fc_branch_pit[active, LOAD_VEC_BRANCHES] = 0 @classmethod diff --git a/src/pandapipes/component_models/junction_component.py b/src/pandapipes/component_models/junction_component.py index 7a1cce558..2f0f77ed5 100644 --- a/src/pandapipes/component_models/junction_component.py +++ b/src/pandapipes/component_models/junction_component.py @@ -8,11 +8,10 @@ from numpy import dtype from pandapipes.component_models.abstract_models.node_models import NodeComponent from pandapipes.component_models.component_toolbox import p_correction_height_air -from pandapipes.idx_node import L, ELEMENT_IDX, RHO, PINIT, node_cols, HEIGHT, TINIT, PAMB, \ +from pandapipes.idx_node import L, ELEMENT_IDX, PINIT, node_cols, HEIGHT, TINIT, PAMB, \ ACTIVE as ACTIVE_ND from pandapipes.pf.pipeflow_setup import add_table_lookup, get_table_number, \ get_lookup -from pandapipes.properties.fluids import get_fluid class Junction(NodeComponent): @@ -83,7 +82,6 @@ def create_pit_node_entries(cls, net, node_pit): junction_pit[:, HEIGHT] = junctions.height_m.values junction_pit[:, PINIT] = junctions.pn_bar.values junction_pit[:, TINIT] = junctions.tfluid_k.values - junction_pit[:, RHO] = get_fluid(net).get_density(junction_pit[:, TINIT]) junction_pit[:, PAMB] = p_correction_height_air(junction_pit[:, HEIGHT]) junction_pit[:, ACTIVE_ND] = junctions.in_service.values diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 550eb1ff1..c51373879 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -11,9 +11,8 @@ from pandapipes.component_models.junction_component import Junction from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \ - VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC -from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, \ - RHO as RHO_NODES, PAMB, ACTIVE as ACTIVE_ND + MINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC +from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, PAMB, ACTIVE as ACTIVE_ND from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \ extract_branch_results_without_internals @@ -115,7 +114,6 @@ def create_pit_node_entries(cls, net, node_pit): junction_pit[tj_nodes, TINIT_NODE], int_node_number) int_node_pit[:, PAMB] = p_correction_height_air(int_node_pit[:, HEIGHT]) - int_node_pit[:, RHO_NODES] = get_fluid(net).get_density(int_node_pit[:, TINIT_NODE]) int_node_pit[:, ACTIVE_ND] = \ np.repeat(net[cls.table_name()][cls.active_identifier()].values, int_node_number) @@ -152,6 +150,7 @@ def create_pit_branch_entries(cls, net, branch_pit): pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals) pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4 + pipe_pit[:, MINIT] *= pipe_pit[:, AREA] * get_fluid(net).get_density(NORMAL_TEMPERATURE) @classmethod def extract_results(cls, net, options, branch_results, mode): @@ -226,22 +225,22 @@ def get_internal_results(cls, net, pipe): selected_indices_v_final = np.logical_or.reduce(selected_indices_v[:]) p_nodes = int_p_lookup[:, 1][selected_indices_p_final] - v_nodes = int_v_lookup[:, 1][selected_indices_v_final] + m_nodes = int_v_lookup[:, 1][selected_indices_v_final] - v_pipe_data = pipe_pit[v_nodes, VINIT] + v_pipe_data = pipe_pit[m_nodes, MINIT] / fluid.get_density(NORMAL_TEMPERATURE) / pipe_pit[m_nodes, AREA] p_node_data = node_pit[p_nodes, PINIT] t_node_data = node_pit[p_nodes, TINIT_NODE] gas_mode = fluid.is_gas if gas_mode: - from_nodes = pipe_pit[v_nodes, FROM_NODE].astype(np.int32) - to_nodes = pipe_pit[v_nodes, TO_NODE].astype(np.int32) + from_nodes = pipe_pit[m_nodes, FROM_NODE].astype(np.int32) + to_nodes = pipe_pit[m_nodes, TO_NODE].astype(np.int32) p_from = node_pit[from_nodes, PAMB] + node_pit[from_nodes, PINIT] p_to = node_pit[to_nodes, PAMB] + node_pit[to_nodes, PINIT] p_mean = np.where(p_from == p_to, p_from, 2 / 3 * (p_from ** 3 - p_to ** 3) / (p_from ** 2 - p_to ** 2)) - numerator = NORMAL_PRESSURE * node_pit[v_nodes, TINIT_NODE] + numerator = NORMAL_PRESSURE * node_pit[m_nodes, TINIT_NODE] normfactor_mean = numerator * fluid.get_property("compressibility", p_mean) \ / (p_mean * NORMAL_TEMPERATURE) normfactor_from = numerator * fluid.get_property("compressibility", p_from) \ diff --git a/src/pandapipes/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py index 1c5aad2e7..b2e5b3de1 100644 --- a/src/pandapipes/component_models/pressure_control_component.py +++ b/src/pandapipes/component_models/pressure_control_component.py @@ -9,7 +9,7 @@ BranchWZeroLengthComponent from pandapipes.component_models.junction_component import Junction from pandapipes.idx_branch import D, AREA, \ - JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DV, BRANCH_TYPE, LOSS_COEFFICIENT as LC + JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, BRANCH_TYPE, LOSS_COEFFICIENT as LC from pandapipes.idx_node import PINIT, NODE_TYPE, PC from pandapipes.pf.pipeflow_setup import get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -77,7 +77,7 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo pc_branch = press_pit[:, BRANCH_TYPE] == PC press_pit[pc_branch, JAC_DERIV_DP] = 0 press_pit[pc_branch, JAC_DERIV_DP1] = 0 - press_pit[pc_branch, JAC_DERIV_DV] = 0 + press_pit[pc_branch, JAC_DERIV_DM] = 0 @classmethod def extract_results(cls, net, options, branch_results, mode): diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index 411209a2b..4021ff2b2 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -12,7 +12,7 @@ from pandapipes.component_models.component_toolbox import get_component_array from pandapipes.component_models.junction_component import Junction from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE, R_UNIVERSAL, P_CONVERSION -from pandapipes.idx_branch import VINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL +from pandapipes.idx_branch import MINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL from pandapipes.idx_node import PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import get_fluid, get_net_option, get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -104,7 +104,7 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo # p_to = node_pit[to_nodes, PAMB] + node_pit[to_nodes, PINIT] t_from = node_pit[from_nodes, TINIT_NODE] numerator_from = NORMAL_PRESSURE * t_from - v_mps = pump_branch_pit[:, VINIT] + v_mps = pump_branch_pit[:, MINIT] / pump_branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) if fluid.is_gas: # consider volume flow at inlet normfactor_from = numerator_from * fluid.get_property("compressibility", p_from) \ diff --git a/src/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py index 5104ea279..7da13eccd 100644 --- a/src/pandapipes/idx_branch.py +++ b/src/pandapipes/idx_branch.py @@ -14,34 +14,31 @@ LENGTH = 5 # Pipe length in [m] D = 6 # Diameter in [m] AREA = 7 # Area in [m²] -RHO = 8 # Density in [kg/m^3 -ETA = 9 # Dynamic viscosity in [Pas] -K = 10 # Pipe roughness in [m] -VINIT = 11 # velocity in [m/s] -RE = 12 # Reynolds number -LAMBDA = 13 # Lambda -JAC_DERIV_DV = 14 # Slot for the derivative by velocity -JAC_DERIV_DP = 15 # Slot for the derivative by pressure from_node -JAC_DERIV_DP1 = 16 # Slot for the derivative by pressure to_node -LOAD_VEC_BRANCHES = 17 # Slot for the load vector for the branches -JAC_DERIV_DV_NODE = 18 # Slot for the derivative by velocity for the nodes connected to branch -LOAD_VEC_NODES = 19 # Slot for the load vector of the nodes connected to branch -LOSS_COEFFICIENT = 20 -CP = 21 # Slot for fluid heat capacity values -ALPHA = 22 # Slot for heat transfer coefficient -JAC_DERIV_DT = 23 -JAC_DERIV_DT1 = 24 -LOAD_VEC_BRANCHES_T = 25 -TOUTINIT = 26 # Internal slot for outlet pipe temperature -JAC_DERIV_DT_NODE = 27 # Slot for the derivative fpr T for the nodes connected to branch -LOAD_VEC_NODES_T = 28 -VINIT_T = 29 -FROM_NODE_T = 30 -TO_NODE_T = 31 -QEXT = 32 # heat input in [W] -TEXT = 33 -PL = 34 -TL = 35 # Temperature lift [K] -BRANCH_TYPE = 36 # branch type relevant for the pressure controller +K = 8 # Pipe roughness in [m] +MINIT = 9 # mass in [m/s] +RE = 10 # Reynolds number +LAMBDA = 11 # Lambda +JAC_DERIV_DM = 12 # Slot for the derivative by mass +JAC_DERIV_DP = 13 # Slot for the derivative by pressure from_node +JAC_DERIV_DP1 = 14 # Slot for the derivative by pressure to_node +LOAD_VEC_BRANCHES = 15 # Slot for the load vector for the branches +JAC_DERIV_DM_NODE = 16 # Slot for the derivative by mass for the nodes connected to branch +LOAD_VEC_NODES = 17 # Slot for the load vector of the nodes connected to branch +LOSS_COEFFICIENT = 18 +ALPHA = 19 # Slot for heat transfer coefficient +JAC_DERIV_DT = 20 +JAC_DERIV_DT1 = 21 +LOAD_VEC_BRANCHES_T = 22 +TOUTINIT = 23 # Internal slot for outlet pipe temperature +JAC_DERIV_DT_NODE = 24 # Slot for the derivative fpr T for the nodes connected to branch +LOAD_VEC_NODES_T = 25 +MINIT_T = 26 +FROM_NODE_T = 27 +TO_NODE_T = 28 +QEXT = 29 # heat input in [W] +TEXT = 30 +PL = 31 +TL = 32 # Temperature lift [K] +BRANCH_TYPE = 33 # branch type relevant for the pressure controller -branch_cols = 37 +branch_cols = 34 diff --git a/src/pandapipes/idx_node.py b/src/pandapipes/idx_node.py index 49726cf30..c4394f80b 100644 --- a/src/pandapipes/idx_node.py +++ b/src/pandapipes/idx_node.py @@ -14,15 +14,14 @@ ELEMENT_IDX = 1 # index of the element that this node belongs to (within the given table) NODE_TYPE = 2 # junction type ACTIVE = 3 -RHO = 4 # Density in [kg/m^3] -PINIT = 5 -LOAD = 6 -HEIGHT = 7 -TINIT = 8 -PAMB = 9 # Ambient pressure in [bar] -LOAD_T = 10 # Heat power drawn in [W] -NODE_TYPE_T = 11 -EXT_GRID_OCCURENCE = 12 -EXT_GRID_OCCURENCE_T = 13 +PINIT = 4 +LOAD = 5 +HEIGHT = 6 +TINIT = 7 +PAMB = 8 # Ambient pressure in [bar] +LOAD_T = 9 # Heat power drawn in [W] +NODE_TYPE_T = 10 +EXT_GRID_OCCURENCE = 11 +EXT_GRID_OCCURENCE_T = 12 -node_cols = 14 +node_cols = 13 diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index e388d2f84..51a17c717 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -3,8 +3,8 @@ # 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 pandapipes.idx_branch import FROM_NODE, TO_NODE, JAC_DERIV_DV, JAC_DERIV_DP, JAC_DERIV_DP1, \ - JAC_DERIV_DV_NODE, LOAD_VEC_NODES, LOAD_VEC_BRANCHES, JAC_DERIV_DT, JAC_DERIV_DT1, \ +from pandapipes.idx_branch import FROM_NODE, TO_NODE, JAC_DERIV_DM, JAC_DERIV_DP, JAC_DERIV_DP1, \ + JAC_DERIV_DM_NODE, LOAD_VEC_NODES, LOAD_VEC_BRANCHES, JAC_DERIV_DT, JAC_DERIV_DT1, \ JAC_DERIV_DT_NODE, LOAD_VEC_NODES_T, LOAD_VEC_BRANCHES_T, FROM_NODE_T, TO_NODE_T, BRANCH_TYPE from pandapipes.idx_node import LOAD, TINIT from pandapipes.idx_node import P, PC, NODE_TYPE, T, NODE_TYPE_T @@ -67,16 +67,16 @@ def build_system_matrix(net, branch_pit, node_pit, heat_mode): if not heat_mode: # pdF_dv - system_data[:len_b] = branch_pit[:, JAC_DERIV_DV] + system_data[:len_b] = branch_pit[:, JAC_DERIV_DM] # pdF_dpi system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DP] # pdF_dpi1 system_data[2 * len_b:3 * len_b] = branch_pit[:, JAC_DERIV_DP1] # jdF_dv_from_nodes - system_data[3 * len_b:len_fn1] = branch_pit[not_slack_fn_branch_mask, JAC_DERIV_DV_NODE] + system_data[3 * len_b:len_fn1] = branch_pit[not_slack_fn_branch_mask, JAC_DERIV_DM_NODE] # jdF_dv_to_nodes system_data[len_fn1:len_tn1] = branch_pit[not_slack_tn_branch_mask, - JAC_DERIV_DV_NODE] * (-1) + JAC_DERIV_DM_NODE] * (-1) # pc_nodes and p_nodes system_data[len_tn1:] = 1 else: diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 7298adbd8..1442a9aa0 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -1,11 +1,13 @@ import numpy as np -from pandapipes.idx_branch import LENGTH, ETA, RHO, D, K, RE, LAMBDA, LOAD_VEC_BRANCHES, \ - JAC_DERIV_DV, JAC_DERIV_DP, JAC_DERIV_DP1, LOAD_VEC_NODES, JAC_DERIV_DV_NODE, VINIT, \ - FROM_NODE, TO_NODE, CP, VINIT_T, FROM_NODE_T, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ - LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE +from pandapipes.idx_branch import LENGTH, D, K, RE, LAMBDA, LOAD_VEC_BRANCHES, \ + JAC_DERIV_DM, JAC_DERIV_DP, JAC_DERIV_DP1, LOAD_VEC_NODES, JAC_DERIV_DM_NODE, \ + FROM_NODE, TO_NODE, FROM_NODE_T, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ + LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE, MINIT, MINIT_T from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.properties.fluids import get_fluid +from pandapipes.constants import NORMAL_TEMPERATURE +from pandapipes.properties.properties_toolbox import get_branch_density, get_branch_eta, get_branch_cp def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): @@ -25,12 +27,15 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): fluid = get_fluid(net) gas_mode = fluid.is_gas friction_model = options["friction_model"] + rho = get_branch_density(net, fluid, node_pit, branch_pit) + eta = get_branch_eta(net, fluid, node_pit, branch_pit) + rho_n = fluid.get_density([NORMAL_TEMPERATURE] * len(branch_pit)) lambda_, re = calc_lambda( - branch_pit[:, VINIT], branch_pit[:, ETA], branch_pit[:, RHO], branch_pit[:, D], - branch_pit[:, K], gas_mode, friction_model, branch_pit[:, LENGTH], options) - der_lambda = calc_der_lambda(branch_pit[:, VINIT], branch_pit[:, ETA], branch_pit[:, RHO], - branch_pit[:, D], branch_pit[:, K], friction_model, lambda_) + branch_pit[:, MINIT], eta, branch_pit[:, D], + branch_pit[:, K], gas_mode, friction_model, branch_pit[:, LENGTH], options, branch_pit[:, AREA]) + der_lambda = calc_der_lambda(branch_pit[:, MINIT], eta, + branch_pit[:, D], branch_pit[:, K], friction_model, lambda_, branch_pit[:, AREA]) branch_pit[:, RE] = re branch_pit[:, LAMBDA] = lambda_ from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) @@ -46,8 +51,8 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): from pandapipes.pf.derivative_toolbox import derivatives_hydraulic_incomp_np \ as derivatives_hydraulic_incomp - load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 = derivatives_hydraulic_incomp( - branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference) + load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 = derivatives_hydraulic_incomp( + branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, rho, rho_n) else: if options["use_numba"]: from pandapipes.pf.derivative_toolbox_numba import derivatives_hydraulic_comp_numba \ @@ -62,27 +67,26 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): # TODO: this might not be required der_comp = fluid.get_der_compressibility() * der_p_m der_comp1 = fluid.get_der_compressibility() * der_p_m1 - load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 = derivatives_hydraulic_comp( + load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 = derivatives_hydraulic_comp( node_pit, branch_pit, lambda_, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, - comp_fact, der_comp, der_comp1) + comp_fact, der_comp, der_comp1, rho, rho_n) branch_pit[:, LOAD_VEC_BRANCHES] = load_vec - branch_pit[:, JAC_DERIV_DV] = df_dv + branch_pit[:, JAC_DERIV_DM] = df_dm branch_pit[:, JAC_DERIV_DP] = df_dp branch_pit[:, JAC_DERIV_DP1] = df_dp1 branch_pit[:, LOAD_VEC_NODES] = load_vec_nodes - branch_pit[:, JAC_DERIV_DV_NODE] = df_dv_nodes + branch_pit[:, JAC_DERIV_DM_NODE] = df_dm_nodes def calculate_derivatives_thermal(net, branch_pit, node_pit, options): - cp = branch_pit[:, CP] - rho = branch_pit[:, RHO] - v_init = branch_pit[:, VINIT_T] + fluid = get_fluid(net) + cp = get_branch_cp(net, fluid, node_pit, branch_pit) + m_init = branch_pit[:, MINIT_T] from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) t_init_i = node_pit[from_nodes, TINIT_NODE] t_init_i1 = branch_pit[:, TOUTINIT] t_amb = branch_pit[:, TEXT] - area = branch_pit[:, AREA] length = branch_pit[:, LENGTH] alpha = branch_pit[:, ALPHA] * np.pi * branch_pit[:, D] tl = branch_pit[:, TL] @@ -90,15 +94,13 @@ def calculate_derivatives_thermal(net, branch_pit, node_pit, options): t_m = (t_init_i1 + t_init_i) / 2 branch_pit[:, LOAD_VEC_BRANCHES_T] = \ - -(rho * area * cp * v_init * (-t_init_i + t_init_i1 - tl) - - alpha * (t_amb - t_m) * length + qext) + -(cp * m_init * (-t_init_i + t_init_i1 - tl) - alpha * (t_amb - t_m) * length + qext) - branch_pit[:, JAC_DERIV_DT] = - rho * area * cp * v_init + alpha / 2 * length - branch_pit[:, JAC_DERIV_DT1] = rho * area * cp * v_init + alpha / 2 * length + branch_pit[:, JAC_DERIV_DT] = - cp * m_init + alpha / 2 * length + branch_pit[:, JAC_DERIV_DT1] = cp * m_init + alpha / 2 * length - branch_pit[:, JAC_DERIV_DT_NODE] = rho * v_init * branch_pit[:, AREA] - branch_pit[:, LOAD_VEC_NODES_T] = rho * v_init * branch_pit[:, AREA] \ - * t_init_i1 + branch_pit[:, JAC_DERIV_DT_NODE] = m_init + branch_pit[:, LOAD_VEC_NODES_T] = m_init * t_init_i1 def get_derived_values(node_pit, from_nodes, to_nodes, use_numba): @@ -109,14 +111,14 @@ def get_derived_values(node_pit, from_nodes, to_nodes, use_numba): return calc_derived_values_np(node_pit, from_nodes, to_nodes) -def calc_lambda(v, eta, rho, d, k, gas_mode, friction_model, lengths, options): +def calc_lambda(m, eta, d, k, gas_mode, friction_model, lengths, options, area): """ Function calculates the friction factor of a pipe. Turbulence is calculated based on Nikuradse. If v equals 0, a value of 0.001 is used in order to avoid division by zero. This should not be a problem as the pressure loss term will equal zero (lambda * u^2). - :param v: - :type v: + :param m: + :type m: :param eta: :type eta: :param rho: @@ -145,9 +147,9 @@ def calc_lambda(v, eta, rho, d, k, gas_mode, friction_model, lengths, options): calc_lambda_nikuradse_incomp, colebrook_np as colebrook, \ calc_lambda_nikuradse_comp_np as calc_lambda_nikuradse_comp if gas_mode: - re, lambda_laminar, lambda_nikuradse = calc_lambda_nikuradse_comp(v, d, k, eta, rho) + re, lambda_laminar, lambda_nikuradse = calc_lambda_nikuradse_comp(m, d, k, eta, area) else: - re, lambda_laminar, lambda_nikuradse = calc_lambda_nikuradse_incomp(v, d, k, eta, rho) + re, lambda_laminar, lambda_nikuradse = calc_lambda_nikuradse_incomp(m, d, k, eta, area) if friction_model == "colebrook": # TODO: move this import to top level if possible @@ -170,7 +172,7 @@ def calc_lambda(v, eta, rho, d, k, gas_mode, friction_model, lengths, options): return lambda_tot, re -def calc_der_lambda(v, eta, rho, d, k, friction_model, lambda_pipe): +def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area): """ Function calculates the derivative of lambda with respect to v. Turbulence is calculated based on Nikuradse. This should not be a problem as the pressure loss term will equal zero @@ -195,28 +197,28 @@ def calc_der_lambda(v, eta, rho, d, k, friction_model, lambda_pipe): """ # TODO: check if some formulas with constants can be shortened - v_corr = np.where(np.abs(v) < 0.00001, 0.00001, v) + m_corr = np.where(np.abs(m) < 0.00001, 0.00001, m) if friction_model == "colebrook": - b_term = 2.51 * eta / (rho * d * np.sqrt(lambda_pipe) * v_corr) + k / (3.71 * d) + b_term = 2.51 * eta * area / (m_corr * d * np.sqrt(lambda_pipe)) + k / (3.71 * d) - df_dv = -2 * (2.51 * eta / (rho * np.sqrt(lambda_pipe) * v_corr ** 2)) \ + df_dm = -2 * 2.51 * eta * area / (m_corr ** 2 * np.sqrt(lambda_pipe) * d) \ / (np.log(10) * b_term) - df_dlambda = -0.5 * lambda_pipe ** (-3 / 2) - (2.51 * eta / (rho * d * v_corr)) \ + df_dlambda = -0.5 * lambda_pipe ** (-3 / 2) - (2.51 * eta * area / (d * m_corr)) \ * lambda_pipe ** (-3 / 2) / (np.log(10) * b_term) - lambda_colebrook_der = df_dv / df_dlambda + lambda_colebrook_der = df_dm / df_dlambda return lambda_colebrook_der elif friction_model == "swamee-jain": - param = k / (3.7 * d) + 5.74 * (np.abs(eta)) ** 0.9 / ((np.abs(rho * v_corr * d)) ** 0.9) + param = k / (3.7 * d) + 5.74 * (np.abs(eta * area)) ** 0.9 / ((np.abs(m_corr * d)) ** 0.9) # 0.5 / (log(10) * log(param)^3 * param) * 5.166 * abs(eta)^0.9 / (abs(rho * d)^0.9 # * abs(v_corr)^1.9) - lambda_swamee_jain_der = 0.5 / np.log(10) / (np.log(param) ** 3) / param * 5.166 \ - * np.abs(eta) ** 0.9 / ((np.abs(rho * d) ** 0.9) - * np.abs(v_corr) ** 1.9) + lambda_swamee_jain_der = 0.5 * np.log(10) ** 2 / (np.log(param) ** 3) / param * 5.166 \ + * np.abs(eta * area) ** 0.9 / ((np.abs(d) ** 0.9) + * np.abs(m_corr) ** 1.9) return lambda_swamee_jain_der else: - lambda_laminar_der = -(64 * eta) / (rho * v_corr ** 2 * d) + lambda_laminar_der = -(64 * eta * area) / (m_corr ** 2 * d) return lambda_laminar_der diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 91c2c6b25..d33ae967b 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -6,11 +6,10 @@ import inspect import numpy as np -from pandapower.auxiliary import ppException from scipy.sparse import coo_matrix, csgraph from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ - ACTIVE as ACTIVE_BR, VINIT + ACTIVE as ACTIVE_BR, MINIT from pandapipes.idx_node import NODE_TYPE, P, NODE_TYPE_T, node_cols, T, ACTIVE as ACTIVE_ND, \ TABLE_IDX as TABLE_IDX_ND, ELEMENT_IDX as ELEMENT_IDX_ND from pandapipes.pf.internals_toolbox import _sum_by_group @@ -33,11 +32,11 @@ logger = logging.getLogger(__name__) -default_options = {"friction_model": "nikuradse", "tol_p": 1e-4, "tol_v": 1e-4, +default_options = {"friction_model": "nikuradse", "tol_p": 1e-4, "tol_m": 1e-4, "tol_T": 1e-3, "tol_res": 1e-3, "iter": 10, "error_flag": False, "alpha": 1, "nonlinear_method": "constant", "mode": "hydraulics", "ambient_temperature": 293, "check_connectivity": True, - "max_iter_colebrook": 100, "only_update_hydraulic_matrix": False, + "max_iter_colebrook": 10, "only_update_hydraulic_matrix": False, "reuse_internal_data": False, "use_numba": True, "quit_on_inconsistency_connectivity": False, "calc_compression_power": True} @@ -517,8 +516,8 @@ def branches_connected_flow(branch_pit): :rtype: np.array """ # TODO: is this formulation correct or could there be any caveats? - return ~np.isnan(branch_pit[:, VINIT]) \ - & ~np.isclose(branch_pit[:, VINIT], 0, rtol=1e-10, atol=1e-10) + return ~np.isnan(branch_pit[:, MINIT]) \ + & ~np.isclose(branch_pit[:, MINIT], 0, rtol=1e-10, atol=1e-10) def check_connectivity(net, branch_pit, node_pit, mode="hydraulics"): diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 037ffc790..7ff21a7b6 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -1,8 +1,8 @@ import numpy as np from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE -from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, LOAD_VEC_NODES, VINIT, RE, \ - LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT +from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MINIT, RE, \ + LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA from pandapipes.idx_node import TABLE_IDX as TABLE_IDX_NODE, PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option @@ -57,12 +57,12 @@ def extract_all_results(net, calculation_mode): def get_basic_branch_results(net, branch_pit, node_pit): from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) to_nodes = branch_pit[:, TO_NODE].astype(np.int32) - + fluid = get_fluid(net) t0 = node_pit[from_nodes, TINIT_NODE] t1 = node_pit[to_nodes, TINIT_NODE] - mf = branch_pit[:, LOAD_VEC_NODES] - vf = mf / get_fluid(net).get_density((t0 + t1) / 2) - return branch_pit[:, VINIT], mf, vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ + vf = branch_pit[:, MINIT] / fluid.get_density((t0 + t1) / 2) + v = branch_pit[:, MINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] + return v, branch_pit[:, MINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ branch_pit[:, PL] @@ -283,8 +283,8 @@ def extract_results_active_pit(net, mode="hydraulics"): if i not in [not_affected_node_col]]) rows_nodes = np.arange(net["_pit"]["node"].shape[0])[nodes_connected] - result_branch_col = VINIT if mode == "hydraulics" else TOUTINIT - not_affected_branch_col = TOUTINIT if mode == "hydraulics" else VINIT + result_branch_col = MINIT if mode == "hydraulics" else TOUTINIT + not_affected_branch_col = TOUTINIT if mode == "hydraulics" else MINIT copied_branch_cols = np.array([i for i in range(net["_pit"]["branch"].shape[1]) if i not in [FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, not_affected_branch_col]]) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 9d78a84e5..2e2dda8de 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -6,7 +6,7 @@ from numpy import linalg from scipy.sparse.linalg import spsolve -from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, VINIT, TOUTINIT, VINIT_T +from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MINIT, TOUTINIT, MINIT_T from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal @@ -89,7 +89,7 @@ def pipeflow(net, sol_vec=None, **kwargs): "results are available.") else: net["_pit"]["node"][:, PINIT] = sol_vec[:len(node_pit)] - net["_pit"]["branch"][:, VINIT] = sol_vec[len(node_pit):] + net["_pit"]["branch"][:, MINIT] = sol_vec[len(node_pit):] if calculate_hydraulics: reduce_pit(net, node_pit, branch_pit, mode="hydraulics") @@ -114,8 +114,8 @@ def pipeflow(net, sol_vec=None, **kwargs): def hydraulics(net): - max_iter, nonlinear_method, tol_p, tol_v, tol_res = get_net_options( - net, "iter", "nonlinear_method", "tol_p", "tol_v", "tol_res") + max_iter, nonlinear_method, tol_p, tol_m, tol_res = get_net_options( + net, "iter", "nonlinear_method", "tol_p", "tol_m", "tol_res") # Start of nonlinear loop # --------------------------------------------------------------------------------------------- @@ -125,28 +125,28 @@ def hydraulics(net): net["_internal_data"] = dict() # This branch is used to stop the solver after a specified error tolerance is reached - error_v, error_p, residual_norm = [], [], None + error_m, error_p, residual_norm = [], [], None # This loop is left as soon as the solver converged while not net.converged and niter <= max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place - v_init, p_init, v_init_old, p_init_old, epsilon = solve_hydraulics(net) + m_init, p_init, m_init_old, p_init_old, epsilon = solve_hydraulics(net) # Error estimation & convergence plot - dv_init = np.abs(v_init - v_init_old) + dm_init = np.abs(m_init - m_init_old) dp_init = np.abs(p_init - p_init_old) residual_norm = linalg.norm(epsilon) / len(epsilon) - error_v.append(linalg.norm(dv_init) / len(dv_init) if len(dv_init) else 0) + error_m.append(linalg.norm(dm_init) / len(dm_init) if len(dm_init) else 0) error_p.append(linalg.norm(dp_init / len(dp_init))) - finalize_iteration(net, niter, error_p, error_v, residual_norm, nonlinear_method, tol_p, - tol_v, tol_res, p_init_old, v_init_old) + finalize_iteration(net, niter, error_p, error_m, residual_norm, nonlinear_method, tol_p, + tol_m, tol_res, p_init_old, m_init_old) niter += 1 write_internal_results(net, iterations=niter, error_p=error_p[niter - 1], - error_v=error_v[niter - 1], residual_norm=residual_norm) + error_m=error_m[niter - 1], residual_norm=residual_norm) if net.converged: set_user_pf_options(net, hyd_flag=True) @@ -225,14 +225,14 @@ def solve_hydraulics(net): net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) - v_init_old = branch_pit[:, VINIT].copy() + m_init_old = branch_pit[:, MINIT].copy() p_init_old = node_pit[:, PINIT].copy() x = spsolve(jacobian, epsilon) - branch_pit[:, VINIT] += x[len(node_pit):] + branch_pit[:, MINIT] += x[len(node_pit):] node_pit[:, PINIT] += x[:len(node_pit)] * options["alpha"] - return branch_pit[:, VINIT], node_pit[:, PINIT], v_init_old, p_init_old, epsilon + return branch_pit[:, MINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon def solve_temperature(net): @@ -255,11 +255,11 @@ def solve_temperature(net): # Negative velocity values are turned to positive ones (including exchange of from_node and # to_node for temperature calculation - branch_pit[:, VINIT_T] = branch_pit[:, VINIT] + branch_pit[:, MINIT_T] = branch_pit[:, MINIT] branch_pit[:, FROM_NODE_T] = branch_pit[:, FROM_NODE] branch_pit[:, TO_NODE_T] = branch_pit[:, TO_NODE] - mask = branch_pit[:, VINIT] < 0 - branch_pit[mask, VINIT_T] = -branch_pit[mask, VINIT] + mask = branch_pit[:, MINIT] < 0 + branch_pit[mask, MINIT_T] = -branch_pit[mask, MINIT] branch_pit[mask, FROM_NODE_T] = branch_pit[mask, TO_NODE] branch_pit[mask, TO_NODE_T] = branch_pit[mask, FROM_NODE] @@ -313,7 +313,7 @@ def set_damping_factor(net, niter, error): def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_method, tol_1, tol_2, tol_res, vals_1_old, vals_2_old, hydraulic_mode=True): - col1, col2 = (PINIT, VINIT) if hydraulic_mode else (TINIT, TOUTINIT) + col1, col2 = (PINIT, MINIT) if hydraulic_mode else (TINIT, TOUTINIT) # Control of damping factor if nonlinear_method == "automatic": @@ -345,7 +345,7 @@ def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_me def log_final_results(net, niter, residual_norm, hyraulic_mode=True): if hyraulic_mode: solver = "hydraulics" - outputs = ["tol_p", "tol_v"] + outputs = ["tol_p", "tol_m"] else: solver = "heat transfer" outputs = ["tol_T"] diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index 52b9b85eb..e7bcb7857 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -4,6 +4,11 @@ import numpy as np +from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE +from pandapipes.idx_branch import TOUTINIT, FROM_NODE, TO_NODE +from pandapipes.idx_node import TINIT, PINIT, PAMB +from pandapipes.properties.fluids import get_fluid + def calculate_mixture_viscosity(components_viscosities, components_molar_proportions, components_molar_mass): @@ -142,3 +147,40 @@ def calculate_mass_fraction_from_molar_fraction(component_molar_proportions, com com_array[:, 2] = com_array[:, 0] * com_array[:, 1] com_array[:, 3] = com_array[:, 2] / com_array[:, 2].sum() return com_array[:, 3] + + +def get_branch_density(net, fluid, node_pit, branch_pit): + from_nodes = branch_pit[:, FROM_NODE].astype(int) + t_from = node_pit[from_nodes, TINIT] + t_to = branch_pit[:, TOUTINIT] + if fluid.is_gas: + from_p = node_pit[from_nodes, PINIT] + node_pit[from_nodes, PAMB] + to_nodes = branch_pit[:, TO_NODE].astype(int) + to_p = node_pit[to_nodes, PINIT] + node_pit[from_nodes, PAMB] + normal_rho = fluid.get_density(NORMAL_TEMPERATURE) + from_rho = np.divide(normal_rho * NORMAL_TEMPERATURE * from_p, + t_from * NORMAL_PRESSURE * fluid.get_compressibility(from_p)) + to_rho = np.divide(normal_rho * NORMAL_TEMPERATURE * to_p, + t_to * NORMAL_PRESSURE * fluid.get_compressibility(to_p)) + else: + fluid = get_fluid(net) + from_rho = fluid.get_density(t_from) + to_rho = fluid.get_density(t_to) + rho = (from_rho + to_rho) / 2 + return rho + +def get_branch_eta(net, fluid, node_pit, branch_pit): + from_nodes = branch_pit[:, FROM_NODE].astype(int) + t_from = node_pit[from_nodes, TINIT] + t_to = branch_pit[:, TOUTINIT] + tm = (t_from + t_to) / 2 + eta = fluid.get_viscosity(tm) + return eta + +def get_branch_cp(net, fluid, node_pit, branch_pit): + from_nodes = branch_pit[:, FROM_NODE].astype(int) + t_from = node_pit[from_nodes, TINIT] + t_to = branch_pit[:, TOUTINIT] + tm = (t_from + t_to) / 2 + cp = fluid.get_heat_capacity(tm) + return cp \ No newline at end of file diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index fa39eb0e3..0e21ab6d1 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -93,7 +93,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp = net.res_junction.t_k.values @@ -110,7 +110,7 @@ def test_t_type_single_pipe(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, + transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -289,7 +289,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) pandapipes.pipeflow(net, stop_condition="tol", iter=20, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp = net.res_junction.t_k.values @@ -318,7 +318,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", iter=20, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -326,7 +326,6 @@ def test_t_type_tee_2zu_2ab2(use_numba): assert np.all(temp_diff < 0.01) - @pytest.mark.parametrize("use_numba", [True, False]) def test_t_type_tee_2zu_2ab3(use_numba): """ @@ -361,7 +360,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp = net.res_junction.t_k.values @@ -390,7 +389,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", iter=10, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp2 = net2.res_junction.t_k.values diff --git a/src/pandapipes/test/api/test_components/test_pressure_control.py b/src/pandapipes/test/api/test_components/test_pressure_control.py index e1fa1835f..cc3458a4d 100644 --- a/src/pandapipes/test/api/test_components/test_pressure_control.py +++ b/src/pandapipes/test/api/test_components/test_pressure_control.py @@ -37,7 +37,7 @@ def test_pressure_control_from_measurement_parameters(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(internals_data_path, "test_pressure_control.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py index bd974e5a2..ca94fe50d 100644 --- a/src/pandapipes/test/api/test_components/test_pump.py +++ b/src/pandapipes/test/api/test_components/test_pump.py @@ -37,7 +37,7 @@ def test_pump_from_measurement_parameteres(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(internals_data_path, "test_pump.csv"), sep=';') @@ -206,9 +206,9 @@ def test_compression_power(use_numba): j3 = pandapipes.create_junction(net, pn_bar=1.05, tfluid_k=293.15, height_m=height_asl_m+10) _ = pandapipes.create_pipe_from_parameters(net, from_junction=j0, to_junction=j1, length_km=0.1, - diameter_m=0.05) + diameter_m=0.05) _ = pandapipes.create_pipe_from_parameters(net, from_junction=j2, to_junction=j3, length_km=0.5, - diameter_m=0.05) + diameter_m=0.05) _ = pandapipes.create_pump(net, from_junction=j1, to_junction=j2, std_type="P2", name="Pump1") @@ -225,7 +225,7 @@ def test_compression_power(use_numba): R_spec = R_UNIVERSAL * 1e3 / pandapipes.get_fluid(net).get_molar_mass() cp = pandapipes.get_fluid(net).get_heat_capacity(293.15) cv = cp - R_spec - k = cp/cv + k = cp / cv pressure_ratio = ((net.res_pump.p_to_bar[0] + p_amb_bar_j2) / (net.res_pump.p_from_bar[0] + p_amb_bar_j1)) compr = pandapipes.get_fluid(net).get_compressibility(net.res_pump.p_from_bar[0] + + p_amb_bar_j1) @@ -235,4 +235,4 @@ def test_compression_power(use_numba): if __name__ == '__main__': - n = pytest.main(["test_pump.py"]) \ No newline at end of file + n = pytest.main(["test_pump.py"]) diff --git a/src/pandapipes/test/api/test_components/test_valve.py b/src/pandapipes/test/api/test_components/test_valve.py index bef0df3ae..fc4d635be 100644 --- a/src/pandapipes/test/api/test_components/test_valve.py +++ b/src/pandapipes/test/api/test_components/test_valve.py @@ -49,7 +49,7 @@ def test_valve(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-8, tol_v=1e-8, use_numba=use_numba) + tol_p=1e-8, tol_m=1e-8, use_numba=use_numba) data = pd.read_csv(os.path.join(internals_data_path, "test_valve.csv"), sep=';') data_p = data['p'].dropna(inplace=False) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 2768f1ea8..dc8b69e37 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -9,8 +9,8 @@ import pandapipes from pandapipes.pf.pipeflow_setup import get_lookup -from pandapipes.pipeflow import PipeflowNotConverged from pandapipes.pipeflow import logger as pf_logger +from pandapipes.pipeflow import PipeflowNotConverged try: import pandaplan.core.pplog as logging diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index 267dec5db..6bdb14f87 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -10,11 +10,12 @@ import pytest import pandapipes -from pandapipes.idx_branch import VINIT +from pandapipes.constants import NORMAL_TEMPERATURE +from pandapipes.idx_branch import MINIT, AREA from pandapipes.idx_node import PINIT -from pandapipes.test import test_path -data_path = os.path.join(test_path, "pipeflow_internals", "data") +from pandapipes.properties import get_fluid +from pandapipes.test import data_path @pytest.fixture @@ -55,7 +56,8 @@ def test_hydraulic_only(simple_test_net, use_numba): p_an = data.loc[1:3, "pv"] p_pandapipes = node_pit[:, PINIT] - v_pandapipes = branch_pit[:, VINIT] + fluid = get_fluid(net) + v_pandapipes = branch_pit[:, MINIT] / branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) p_diff = np.abs(1 - p_pandapipes / p_an) v_diff = np.abs(v_pandapipes - v_an) @@ -93,10 +95,9 @@ def test_heat_only(use_numba): pandapipes.pipeflow(ntw, stop_condition="tol", iter=50, friction_model="nikuradse", nonlinear_method="automatic", mode="hydraulics", use_numba=use_numba) - p = ntw._pit["node"][:, PINIT] - v = ntw._pit["branch"][:, VINIT] - u = np.concatenate((p, v)) + m = ntw._pit["branch"][:, MINIT] + u = np.concatenate((p, m)) pandapipes.pipeflow(ntw, sol_vec=u, stop_condition="tol", iter=50, friction_model="nikuradse", nonlinear_method="automatic", mode="heat", use_numba=use_numba) diff --git a/src/pandapipes/test/pipeflow_internals/test_time_series.py b/src/pandapipes/test/pipeflow_internals/test_time_series.py index 30ff113e6..b82676034 100644 --- a/src/pandapipes/test/pipeflow_internals/test_time_series.py +++ b/src/pandapipes/test/pipeflow_internals/test_time_series.py @@ -6,10 +6,11 @@ import tempfile import numpy as np +import pandapower.control as control import pandas as pd import pytest +from pandapower.timeseries import OutputWriter, DFData -import pandapower.control as control from pandapipes import networks as nw from pandapipes import pp_dir from pandapipes.timeseries import run_timeseries, init_default_outputwriter @@ -22,8 +23,6 @@ logger = logging.getLogger(__name__) -path = os.path.join(pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results') - def _prepare_grid(net): """ @@ -162,7 +161,7 @@ def test_time_series(): time_steps = range(25) # _output_writer(net, time_steps) # , path=os.path.join(ppipe.pp_dir, 'results')) _output_writer(net, time_steps, ow_path=tempfile.gettempdir()) - run_timeseries(net, time_steps, calc_compression_power = False) + run_timeseries(net, time_steps, calc_compression_power=False) ow = net.output_writer.iat[0, 0] _compare_results(ow) @@ -177,7 +176,7 @@ def test_time_series_default_ow(): _prepare_grid(net) time_steps = range(25) init_default_outputwriter(net, time_steps) - run_timeseries(net, time_steps, calc_compression_power = False) + run_timeseries(net, time_steps, calc_compression_power=False) ow = net.output_writer.iat[0, 0] _compare_results(ow) diff --git a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py index 0abdd70ca..af87f95ac 100644 --- a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py @@ -3,8 +3,9 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import numpy as np -import pandapipes.networks.simple_gas_networks as nw import pytest + +import pandapipes.networks.simple_gas_networks as nw from pandapipes.pipeflow import logger as pf_logger from pandapipes.test.stanet_comparison.pipeflow_stanet_comparison import pipeflow_stanet_comparison diff --git a/src/pandapipes/timeseries/run_time_series.py b/src/pandapipes/timeseries/run_time_series.py index 03ff9dd77..34c741677 100644 --- a/src/pandapipes/timeseries/run_time_series.py +++ b/src/pandapipes/timeseries/run_time_series.py @@ -5,13 +5,13 @@ import tempfile from pandapower.control import NetCalculationNotConverged + +from pandapipes.pipeflow import PipeflowNotConverged, pipeflow from pandapower.control.util.diagnostic import control_diagnostic from pandapower.timeseries.output_writer import OutputWriter -from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup, \ +from pandapower.timeseries.run_time_series import init_time_series as init_time_series_pp, cleanup,\ run_loop -from pandapipes.pipeflow import PipeflowNotConverged, pipeflow - try: import pandaplan.core.pplog as logging except ImportError: From 2402b20daa27417ace68b3452883e24dd2a2e568 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:06:19 +0100 Subject: [PATCH 077/237] bug in convert format --- src/pandapipes/io/convert_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py index a4c8b0a45..07136dc08 100644 --- a/src/pandapipes/io/convert_format.py +++ b/src/pandapipes/io/convert_format.py @@ -48,7 +48,7 @@ def _rename_columns(net): for comp in [CirculationPumpMass, CirculationPumpPressure]: cp_tbl = comp.table_name() if cp_tbl in net: - old_cols = ["to_junction", "from_junction", "mdot_kg_per_s", "p_bar", "t_k"] + old_cols = ["from_junction", "to_junction", "mdot_kg_per_s", "p_bar", "t_k"] new_cols = list(comp.from_to_node_cols()) + ["mdot_flow_kg_per_s", "p_flow_bar", "t_flow_k"] for old_col, new_col in list(zip(old_cols, new_cols)): From 1466dacd8ed8025db368fe80c5417cde512009ff Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:07:11 +0100 Subject: [PATCH 078/237] changes in checking compatibility between different versions --- .../release_control_test_network.py | 142 +++++++++++++++++- .../test/api/test_convert_format.py | 20 ++- 2 files changed, 149 insertions(+), 13 deletions(-) diff --git a/src/pandapipes/test/api/release_cycle/release_control_test_network.py b/src/pandapipes/test/api/release_cycle/release_control_test_network.py index 148aaaec4..c8fbae0d5 100644 --- a/src/pandapipes/test/api/release_cycle/release_control_test_network.py +++ b/src/pandapipes/test/api/release_cycle/release_control_test_network.py @@ -19,8 +19,134 @@ logger = logging.getLogger(__name__) path = os.path.join(pp_dir, "test", "api", "old_versions") +def release_control_test_network(save=False): + # empty net + net = pp.create_empty_network("net", add_stdtypes=False) + + # fluid + pp.create_fluid_from_lib(net, "water", overwrite=True) + + # junctions + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 0", index=None, + in_service=True, type="junction", geodata=None) + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 1") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 2") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 3") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 4") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 5") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 6") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 7") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 8") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 9") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 10") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 11") + pp.create_junction(net, pn_bar=3, tfluid_k=293, height_m=0, name="Junction 12") + + # pipes + pp.create_pipe_from_parameters( + net, from_junction=0, to_junction=8, length_km=3, diameter_m=0.01, k_mm=1, + loss_coefficient=0, sections=10, alpha_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", + index=None, geodata=None, in_service=True, type="pipe") + pp.create_pipe_from_parameters( + net, 9, 2, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, alpha_w_per_m2k=3, + name="Pipe 1") + pp.create_pipe_from_parameters( + net, 2, 12, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, alpha_w_per_m2k=20, + name="Pipe 2") + pp.create_pipe_from_parameters( + net, 4, 12, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, alpha_w_per_m2k=2, + name="Pipe 3") + pp.create_pipe_from_parameters( + net, 5, 3, length_km=1, diameter_m=0.09, k_mm=.1, sections=10, alpha_w_per_m2k=3, + name="Pipe 4") + pp.create_pipe_from_parameters( + net, 4, 11, length_km=2.5, diameter_m=0.08, k_mm=.1, sections=10, alpha_w_per_m2k=15, + name="Pipe 5") + pp.create_pipe_from_parameters( + net, 7, 6, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, alpha_w_per_m2k=2.5, + name="Pipe 6") + pp.create_pipe_from_parameters( + net, 1, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1, + name="Pipe 7") + + # external grids + pp.create_ext_grid(net, junction=0, p_bar=3, t_k=300, name="External Grid 0", in_service=True, + index=None, type="pt") + pp.create_ext_grid(net, 1, p_bar=5, t_k=350, name="External Grid 1", type="pt") + + # sinks + pp.create_sink(net, junction=2, mdot_kg_per_s=0.2, scaling=1., name="Sink 0", index=None, + in_service=True, type="sink") + pp.create_sink(net, 3, mdot_kg_per_s=0.1, name="Sink 1") + pp.create_sink(net, 4, mdot_kg_per_s=0.5, name="Sink 2") + pp.create_sink(net, 5, mdot_kg_per_s=0.07, name="Sink 3") + pp.create_sink(net, 6, mdot_kg_per_s=0.09, name="Sink 4") + pp.create_sink(net, 7, mdot_kg_per_s=0.1, name="Sink 5") + + # sources + pp.create_source(net, junction=8, mdot_kg_per_s=0.1, scaling=1., name="Source 0", index=None, + in_service=True, type="source") + pp.create_source(net, junction=9, mdot_kg_per_s=0.03, name="Source 1") + pp.create_source(net, junction=10, mdot_kg_per_s=0.04, name="Source 2") + pp.create_source(net, junction=11, mdot_kg_per_s=0.09, name="Source 3") + + # valves + pp.create_valve(net, from_junction=8, to_junction=9, diameter_m=0.1, opened=True, + loss_coefficient=0, name="Valve 0", index=None, type="valve") + pp.create_valve(net, 9, 4, diameter_m=0.05, opened=True, name="Valve 1") + + # pump + pp.create_pump_from_parameters(net, from_junction=8, to_junction=3, new_std_type_name="Pump", + pressure_list=[6.1, 5.8, 4], + flowrate_list=[0, 19, 83], reg_polynomial_degree=2, + poly_coefficents=None, name=None, index=None, in_service=True, + type="pump") + + # circulation pump mass + pp.create_circ_pump_const_mass_flow( + net, return_junction=3, flow_junction=4, p_flow_bar=6, mdot_flow_kg_per_s=1, t_flow_k=290, + name="Circ. Pump Mass", index=None, in_service=True, type="pt") -def release_control_test_network_water(): + # circulation pump pressure + pp.create_circ_pump_const_pressure( + net, return_junction=11, flow_junction=5, p_flow_bar=5, plift_bar=2, t_flow_k=290, + name="Circ. Pump Pressure", index=None, in_service=True, type="pt") + + # heat exchanger + pp.create_heat_exchanger( + net, from_junction=10, to_junction=6, diameter_m=0.08, qext_w=50, loss_coefficient=0, + name="Heat Exchanger 0", index=None, in_service=True, type="heat_exchanger") + pp.create_heat_exchanger( + net, from_junction=4, to_junction=10, diameter_m=0.08, qext_w=28000, loss_coefficient=0, + name="Heat Exchanger 1", index=None, in_service=True, type="heat_exchanger") + # time series + profiles_sink = pd.read_csv(os.path.join(pp_dir, 'test', 'api', 'release_cycle', + 'release_control_test_sink_profiles.csv'), index_col=0) + profiles_source = pd.read_csv(os.path.join(pp_dir, 'test', 'api', 'release_cycle', + 'release_control_test_source_profiles.csv'), + index_col=0) + ds_sink = DFData(profiles_sink) + ds_source = DFData(profiles_source) + + const_sink = control.ConstControl(net, element='sink', variable='mdot_kg_per_s', + element_index=net.sink.index.values, data_source=ds_sink, + profile_name=net.sink.index.values.astype(str)) + const_source = control.ConstControl(net, element='source', variable='mdot_kg_per_s', + element_index=net.source.index.values, + data_source=ds_source, + profile_name=net.source.index.values.astype(str)) + + const_sink.initial_run = False + const_source.initial_run = False + + pp.pipeflow(net) + + if save: + pp.to_json(net, os.path.join(path, 'example_%s.json' % pp.__version__)) + + return net + +def release_control_test_network_water(save=False): # empty net net = pp.create_empty_network("net", add_stdtypes=False) @@ -120,12 +246,12 @@ def release_control_test_network_water(): pp.pipeflow(net) - pp.to_json(net, os.path.join(path, 'example_%s_water.json' % pp.__version__)) - + if save: + pp.to_json(net, os.path.join(path, 'example_%s_water.json' % pp.__version__)) return net -def release_control_test_network_gas(): +def release_control_test_network_gas(save=False): # empty net net = pp.create_empty_network("net", add_stdtypes=False) @@ -213,8 +339,8 @@ def release_control_test_network_gas(): add_ts_controllers(net) pp.pipeflow(net) - - pp.to_json(net, os.path.join(path, 'example_%s_gas.json' % pp.__version__)) + if save: + pp.to_json(net, os.path.join(path, 'example_%s_gas.json' % pp.__version__)) return net @@ -241,5 +367,5 @@ def add_ts_controllers(net): if __name__ == '__main__': - water_net = release_control_test_network_water() - gas_net = release_control_test_network_gas() + water_net = release_control_test_network_water(True) + gas_net = release_control_test_network_gas(True) diff --git a/src/pandapipes/test/api/test_convert_format.py b/src/pandapipes/test/api/test_convert_format.py index f96b2b0b9..08fbe0b36 100644 --- a/src/pandapipes/test/api/test_convert_format.py +++ b/src/pandapipes/test/api/test_convert_format.py @@ -18,6 +18,8 @@ test_params = list(product(found_versions, numba_usage)) # as of version 0.8.0, water and gas grids were separately created for convert_format testing minimal_version_two_nets = "0.8.0" +from pandapipes.test.api.release_cycle.release_control_test_network import release_control_test_network_gas, \ + release_control_test_network_water, release_control_test_network @pytest.mark.slow @@ -25,9 +27,15 @@ def test_convert_format(pp_version, use_numba): if version.parse(pp_version) >= version.parse(minimal_version_two_nets): names = ["_gas", "_water"] + net_gas = release_control_test_network_gas() + net_water = release_control_test_network_water() else: names = [""] + net_old = release_control_test_network() for name in names: + if "_gas" in name: net_ref = net_gas + elif "_water" in name: net_ref = net_water + else: net_ref = net_old filename = os.path.join(folder, "example_%s%s.json" % (pp_version, name)) if not os.path.isfile(filename): raise ValueError("File for %s grid of version %s does not exist" % (name, pp_version)) @@ -36,8 +44,7 @@ def test_convert_format(pp_version, use_numba): except: raise UserWarning("Can not load %s network saved in pandapipes version %s" % (name, pp_version)) - p_bar_old = net.res_junction.p_bar.copy() - v_mean_m_per_s_old = net.res_pipe.v_mean_m_per_s.copy() + convert_format(net) try: pp.pipeflow(net, run_control="controller" in net and len(net.controller) > 0, @@ -45,10 +52,13 @@ def test_convert_format(pp_version, use_numba): except: raise UserWarning("Can not run pipe flow in %s network " "saved with pandapipes version %s" % (name, pp_version)) - p_res = np.allclose(p_bar_old.values, net.res_junction.p_bar.values) - v_res = np.allclose(v_mean_m_per_s_old.values, net.res_pipe.v_mean_m_per_s.values) + p_bar_old = net.res_junction.p_bar.copy() + v_mean_m_per_s_old = net.res_pipe.v_mean_m_per_s.copy() + + p_res = np.allclose(p_bar_old.values, net_ref.res_junction.p_bar.values) + v_res = np.allclose(v_mean_m_per_s_old.values, net_ref.res_pipe.v_mean_m_per_s.values) if not all([p_res, v_res]): - raise UserWarning("Pipe flow results mismatch in %s grid" + raise UserWarning("Pipe flow results mismatch in %s grid " "with pandapipes version %s" % (name, pp_version)) From 797fcb68590267b405f03604bbf0f188620f23ef Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:08:53 +0100 Subject: [PATCH 079/237] changes in data path --- .../test_components/test_circ_pump_mass.py | 4 ++-- .../test_circ_pump_pressure.py | 4 ++-- .../test/api/test_components/test_ext_grid.py | 6 ++--- .../test_components/test_heat_exchanger.py | 4 ++-- .../test_components/test_pressure_control.py | 5 ++-- .../test/api/test_components/test_pump.py | 8 +++---- .../test/api/test_components/test_valve.py | 5 ++-- .../test_pipeflow_analytic_comparison.py | 18 +++++++-------- .../pipeflow_internals/test_time_series.py | 23 +++++++------------ 9 files changed, 33 insertions(+), 44 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index 3ade57c4e..c41f8f4a4 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -9,7 +9,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -38,7 +38,7 @@ def test_circulation_pump_constant_mass(use_numba): mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_circ_pump_mass.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_circ_pump_mass.csv"), sep=';') res_junction = net.res_junction res_pipe = net.res_pipe.v_mean_m_per_s.values diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index 9e9cdbe6b..77536174d 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -8,7 +8,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -39,7 +39,7 @@ def test_circulation_pump_constant_pressure(use_numba): mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_circ_pump_pressure.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure.csv"), sep=';') res_junction = net.res_junction res_pipe = net.res_pipe.v_mean_m_per_s.values diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index 0e21ab6d1..45a125508 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -9,7 +9,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -63,7 +63,7 @@ def test_p_type(use_numba): transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "ext_grid_p.csv"), + data = pd.read_csv(os.path.join(data_path, "ext_grid_p.csv"), sep=';', header=0, keep_default_na=False) p_comp = data["p"] p_pandapipes = net.res_junction["p_bar"][0] @@ -72,7 +72,6 @@ def test_p_type(use_numba): assert np.all(p_diff < 0.01) - @pytest.mark.parametrize("use_numba", [True, False]) def test_t_type_single_pipe(use_numba): """ @@ -254,7 +253,6 @@ def test_t_type_tee_2zu_2ab(use_numba): assert np.all(temp_diff < 0.01) - @pytest.mark.parametrize("use_numba", [True, False]) def test_t_type_tee_2zu_2ab2(use_numba): """ diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index 08d946778..a2e7b562c 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -8,7 +8,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -33,7 +33,7 @@ def test_heat_exchanger(use_numba): mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "heat_exchanger_test.csv"), sep=';', + data = pd.read_csv(os.path.join(data_path, "heat_exchanger_test.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T1"] diff --git a/src/pandapipes/test/api/test_components/test_pressure_control.py b/src/pandapipes/test/api/test_components/test_pressure_control.py index cc3458a4d..67fc624e3 100644 --- a/src/pandapipes/test/api/test_components/test_pressure_control.py +++ b/src/pandapipes/test/api/test_components/test_pressure_control.py @@ -9,8 +9,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path - +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) def test_pressure_control_from_measurement_parameters(use_numba): @@ -39,7 +38,7 @@ def test_pressure_control_from_measurement_parameters(use_numba): mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_pressure_control.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_pressure_control.csv"), sep=';') res_junction = net.res_junction.p_bar.values res_pipe = net.res_pipe.v_mean_m_per_s.values diff --git a/src/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py index ca94fe50d..4202ff231 100644 --- a/src/pandapipes/test/api/test_components/test_pump.py +++ b/src/pandapipes/test/api/test_components/test_pump.py @@ -9,7 +9,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -39,7 +39,7 @@ def test_pump_from_measurement_parameteres(use_numba): mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_pump.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_pump.csv"), sep=';') res_junction = net.res_junction.p_bar.values res_pipe = net.res_pipe.v_mean_m_per_s.values @@ -81,7 +81,7 @@ def test_pump_from_regression_parameteres(use_numba): mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_pump.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_pump.csv"), sep=';') res_junction = net.res_junction.p_bar.values res_pipe = net.res_pipe.v_mean_m_per_s.values @@ -119,7 +119,7 @@ def test_pump_from_std_type(use_numba): mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_pump.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_pump.csv"), sep=';') res_junction = net.res_junction.p_bar.values res_pipe = net.res_pipe.v_mean_m_per_s.values diff --git a/src/pandapipes/test/api/test_components/test_valve.py b/src/pandapipes/test/api/test_components/test_valve.py index fc4d635be..03a2cc797 100644 --- a/src/pandapipes/test/api/test_components/test_valve.py +++ b/src/pandapipes/test/api/test_components/test_valve.py @@ -8,8 +8,7 @@ import pytest import pandapipes -from pandapipes.test.pipeflow_internals import internals_data_path - +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) def test_valve(use_numba): @@ -51,7 +50,7 @@ def test_valve(use_numba): mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-8, tol_m=1e-8, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "test_valve.csv"), sep=';') + data = pd.read_csv(os.path.join(data_path, "test_valve.csv"), sep=';') data_p = data['p'].dropna(inplace=False) data_v = data['v'].dropna(inplace=False) diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index de52ce872..22b7a138a 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -14,7 +14,7 @@ from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.pipeflow_setup import get_lookup from pandapipes.properties.fluids import _add_fluid_to_net -from pandapipes.test.pipeflow_internals import internals_data_path +from pandapipes.test import data_path @pytest.mark.parametrize("use_numba", [True, False]) @@ -41,7 +41,7 @@ def test_gas_internal_nodes(use_numba): pipe_results = Pipe.get_internal_results(net, [0]) - data = pd.read_csv(os.path.join(internals_data_path, "gas_sections_an.csv"), sep=';', header=0, + data = pd.read_csv(os.path.join(data_path, "gas_sections_an.csv"), sep=';', header=0, keep_default_na=False) p_an = data["p1"] / 1e5 v_an = data["v"] @@ -95,7 +95,7 @@ def test_temperature_internal_nodes_single_pipe(use_numba): pipe_results = Pipe.get_internal_results(net, [0]) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_one_pipe_an.csv"), sep=';', + data = pd.read_csv(os.path.join(data_path, "Temperature_one_pipe_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -145,7 +145,7 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_tee_2ab_1zu_an.csv"), + data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -185,7 +185,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_tee_2zu_1ab_an.csv"), + data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -225,7 +225,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_tee_2zu_1ab_an.csv"), + data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -265,7 +265,7 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_2zu_2ab_an.csv"), sep=';', + data = pd.read_csv(os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -307,7 +307,7 @@ def test_temperature_internal_nodes_masche_1load(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, "Temperature_masche_1load_an.csv"), + data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] @@ -346,7 +346,7 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) - data = pd.read_csv(os.path.join(internals_data_path, + data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_direction_an.csv"), sep=';', header=0, keep_default_na=False) temp_an = data["T"] diff --git a/src/pandapipes/test/pipeflow_internals/test_time_series.py b/src/pandapipes/test/pipeflow_internals/test_time_series.py index b82676034..b49d9d770 100644 --- a/src/pandapipes/test/pipeflow_internals/test_time_series.py +++ b/src/pandapipes/test/pipeflow_internals/test_time_series.py @@ -14,7 +14,7 @@ from pandapipes import networks as nw from pandapipes import pp_dir from pandapipes.timeseries import run_timeseries, init_default_outputwriter -from pandapower.timeseries import OutputWriter, DFData +from pandapipes.test import data_path try: import pandaplan.core.pplog as logging @@ -71,18 +71,15 @@ def _data_source(): :return: Time series values from csv files for sink and source :rtype: DataFrame """ - profiles_sink = pd.read_csv(os.path.join(pp_dir, 'test', 'pipeflow_internals', 'data', - 'test_time_series_sink_profiles.csv'), index_col=0) - profiles_source = pd.read_csv(os.path.join(pp_dir, 'test', 'pipeflow_internals', 'data', - 'test_time_series_source_profiles.csv'), index_col=0) + profiles_sink = pd.read_csv(os.path.join(data_path, 'test_time_series_sink_profiles.csv'), index_col=0) + profiles_source = pd.read_csv(os.path.join(data_path, 'test_time_series_source_profiles.csv'), index_col=0) ds_sink = DFData(profiles_sink) ds_source = DFData(profiles_source) return ds_sink, ds_source def _compare_results(ow): - test_res_ext_grid = pd.read_csv(os.path.join( - pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results', 'res_ext_grid', + test_res_ext_grid = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_ext_grid', 'mdot_kg_per_s.csv'), sep=';', index_col=0) res_ext_grid = ow.np_results["res_ext_grid.mdot_kg_per_s"] res_ext_grid = res_ext_grid[~np.isclose(res_ext_grid, 0)] @@ -90,8 +87,7 @@ def _compare_results(ow): diff = 1 - res_ext_grid.round(9) / test_res_ext_grid.round(9) check = diff < 0.0001 assert (np.all(check)) - test_res_junction = pd.read_csv(os.path.join( - pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results', 'res_junction', + test_res_junction = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_junction', 'p_bar.csv'), sep=';', index_col=0) res_junction = ow.np_results["res_junction.p_bar"] res_junction = res_junction[~np.isclose(res_junction, 0)] @@ -99,8 +95,7 @@ def _compare_results(ow): diff = 1 - res_junction.round(9) / test_res_junction.round(9) check = diff < 0.0001 assert (np.all(check)) - test_res_pipe = pd.read_csv(os.path.join( - pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results', 'res_pipe', + test_res_pipe = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_pipe', 'v_mean_m_per_s.csv'), sep=';', index_col=0) res_pipe = ow.np_results["res_pipe.v_mean_m_per_s"] res_pipe = res_pipe[~np.isclose(res_pipe, 0)] @@ -108,8 +103,7 @@ def _compare_results(ow): diff = 1 - res_pipe.round(9) / test_res_pipe.round(9) check = diff < 0.0001 assert (np.all(check)) - test_res_sink = pd.read_csv(os.path.join( - pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results', 'res_sink', + test_res_sink = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_sink', 'mdot_kg_per_s.csv'), sep=';', index_col=0) res_sink = ow.np_results["res_sink.mdot_kg_per_s"] res_sink = res_sink[~np.isclose(res_sink, 0)] @@ -117,8 +111,7 @@ def _compare_results(ow): diff = 1 - res_sink.round(9) / test_res_sink.round(9) check = diff < 0.0001 assert (np.all(check)) - test_res_source = pd.read_csv(os.path.join( - pp_dir, 'test', 'pipeflow_internals', 'data', 'test_time_series_results', + test_res_source = pd.read_csv(os.path.join(data_path, 'test_time_series_results', 'res_source', 'mdot_kg_per_s.csv'), sep=';', index_col=0) res_source = ow.np_results["res_source.mdot_kg_per_s"] res_source = res_source[~np.isclose(res_source, 0)] From 070d6837fd20a906a9d27c266d0d9741477784fe Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:09:10 +0100 Subject: [PATCH 080/237] result changes due to norm state --- .../test/data/test_pressure_control.csv | 5 ++++ src/pandapipes/test/data/test_pump.csv | 5 ++++ .../res_pipe/v_mean_m_per_s.csv | 26 +++++++++++++++++++ src/pandapipes/test/data/test_valve.csv | 9 +++++++ .../data/test_pressure_control.csv | 5 ---- .../pipeflow_internals/data/test_pump.csv | 5 ---- .../res_pipe/v_mean_m_per_s.csv | 26 ------------------- .../pipeflow_internals/data/test_valve.csv | 9 ------- 8 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 src/pandapipes/test/data/test_pressure_control.csv create mode 100644 src/pandapipes/test/data/test_pump.csv create mode 100644 src/pandapipes/test/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv create mode 100644 src/pandapipes/test/data/test_valve.csv delete mode 100644 src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv delete mode 100644 src/pandapipes/test/pipeflow_internals/data/test_pump.csv delete mode 100644 src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv delete mode 100644 src/pandapipes/test/pipeflow_internals/data/test_valve.csv diff --git a/src/pandapipes/test/data/test_pressure_control.csv b/src/pandapipes/test/data/test_pressure_control.csv new file mode 100644 index 000000000..bd365c076 --- /dev/null +++ b/src/pandapipes/test/data/test_pressure_control.csv @@ -0,0 +1,5 @@ +v;p +2.95329199;5.000000 +3.31572875;25.57238 +;23.86160 +;20.00000 \ No newline at end of file diff --git a/src/pandapipes/test/data/test_pump.csv b/src/pandapipes/test/data/test_pump.csv new file mode 100644 index 000000000..7dd28f9a6 --- /dev/null +++ b/src/pandapipes/test/data/test_pump.csv @@ -0,0 +1,5 @@ +v;p +0.61319788;5.000000 +0.30766539;4.99846063 +;10.80254845 +;10.80207844 \ No newline at end of file diff --git a/src/pandapipes/test/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv b/src/pandapipes/test/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv new file mode 100644 index 000000000..c43ca44f1 --- /dev/null +++ b/src/pandapipes/test/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv @@ -0,0 +1,26 @@ +;0;1;2;3;4;5;6;7;8;9;10;11 +0;2.209712676666369;-0.11889137662082647;0.23039922365484475;0.027924558850555958;-0.12093989490378775;0.012579144230318327;0.0066664762611603956;0.06498808332165647;-0.27506696941543574;0.10597444121593402;0.0;0.0 +1;2.2090881368758843;-0.11616180416209484;0.22656972560591923;0.06269648022156891;-0.10569206483657707;0.03625253036460436;0.0011995876331315966;0.007209839209659238;-0.28572343176977727;0.10025367510057467;0.0;0.0 +2;2.2089882843921487;-0.1143687951626792;0.22429617426175852;0.0439491146428944;-0.09178798891103848;0.054976946490246384;0.003303594235725901;0.02946479563753642;-0.28654845978774846;0.1005687419896497;0.0;0.0 +3;2.2092224917846757;-0.11877167256367754;0.23047592819007715;0.05766768796608639;-0.11765394621217357;0.017757636833010723;0.0019408801903003847;0.013374931911661832;-0.25137049212322177;0.10323311232975428;0.0;0.0 +4;2.2091174018537014;-0.11873755532808311;0.23232150031239024;0.06194778189079287;-0.09493157200481693;0.05839255075118776;0.002693902443873143;0.019484097100972965;-0.2799886789847636;0.10272765771653758;0.0;0.0 +5;2.2095370438170914;-0.11681734727537363;0.2284525130019489;0.013762650796999717;-0.0979379193544127;0.04927761798441479;0.007708993499567872;0.0712824159947594;-0.2458202604742915;0.10497201984674791;0.0;0.0 +6;2.209826377828252;-0.11546367164332533;0.22644574919463498;0.06855812396412621;-0.09075804626671068;0.05712166135058977;0.0025402939635266884;0.022754095041129158;-0.27038789520832573;0.09889211283832981;0.0;0.0 +7;2.209250175742973;-0.11585704767105423;0.2250597115930902;0.015266301725944266;-0.11615180083103904;0.013499393780460193;0.005430480216779369;0.05060713120794306;-0.2773467431765606;0.1040286192637538;0.0;0.0 +8;2.208960255174726;-0.11885490927220654;0.2303920704816874;0.048932096851859785;-0.12027857185326524;0.013349022135979605;0.0018929467243566649;0.014030847594424864;-0.2577552926437905;0.10420188420534011;0.0;0.0 +9;2.2091913508691237;-0.11643266517816848;0.22648857215087692;0.027912505007002524;-0.11251056931530984;0.02393840557705914;0.005442099590629899;0.05147183218006001;-0.28157864004647687;0.10375366472941429;0.0;0.0 +10;2.209531447197588;-0.11678881201522394;0.22617026766977527;0.014163216649633489;-0.123201435074322;0.001400623996575589;0.0048788829315563045;0.044843098513515346;-0.24386497031307838;0.10492492562977421;0.0;0.0 +11;2.209498814551714;-0.11627497561863764;0.22609826797731547;0.053200740191595014;-0.11350130800202213;0.02238763859841396;0.0007638564902407718;0.006428978224045114;-0.2808869914077911;0.10140628527967645;0.0;0.0 +12;2.2094914666055163;-0.1160281196929072;0.22573129925998;0.07747166829142976;-0.11235614447358347;0.0186225606546111;0.0005972049622964697;9.423706902368104e-05;-0.29367081607374224;0.09824585248700742;0.0;0.0 +13;2.209169583242883;-0.11761265536731196;0.22789781248318214;0.07905864694708904;-0.12159457120881073;0.0079066186051938;0.0006733588406979844;0.003315684279479123;-0.2554205723462112;0.09952013978991552;0.0;0.0 +14;2.209611440880294;-0.11690347992222468;0.22699834990948628;0.022446897939594188;-0.11676025417036012;0.01491152842420094;0.003841740489464515;0.03205016249189214;-0.2847909414257794;0.10454503566997297;0.0;0.0 +15;2.2094653030164806;-0.1153970705313719;0.2250397924508725;0.06649418920352763;-0.10657435028191271;0.033281272087828655;0.0027919325548586005;0.02253404969176886;-0.24766163524465834;0.09908656887516157;0.0;0.0 +16;2.2095603003426243;-0.11420445022724135;0.22368264163922102;0.011041901652634743;-0.09564554095348701;0.051735932800534054;0.0077116339080327365;0.07114434273679948;-0.24047228236570756;0.10276659948085749;0.0;0.0 +17;2.2095877517932627;-0.11741333247520776;0.22833346798925777;0.037856908017399;-0.11274749764630218;0.02185038711398942;0.0015381562761079472;0.013389931093118982;-0.25632639313356287;0.10387891119824945;0.0;0.0 +18;2.209303888462985;-0.11694776650402224;0.22722505889621197;0.04476291917070764;-0.11520934720122034;0.018071439992003436;0.003770424176489887;0.03650204974987347;-0.26819182372912287;0.10285026668165996;0.0;0.0 +19;2.2088690177633548;-0.1165924109297661;0.22845983791128574;0.021862645996541512;-0.09238138201040323;0.059464758916314996;0.005072882784932804;0.0447324392026431;-0.29844967713777665;0.10430239063936324;0.0;0.0 +20;2.2092801821645662;-0.117757539565524;0.22914600050442888;0.07420391923905686;-0.11096755078750226;0.028965585387173205;0.0005831954881997788;0.003938804195768295;-0.28075912189454283;0.1003122228350167;0.0;0.0 +21;2.2093386688353003;-0.11604604474138074;0.22617294352923165;0.06080998900048506;-0.10774235937310515;0.031599515057612444;0.0002156040542288165;0.0005480719111064454;-0.2521456235369519;0.10036437574849619;0.0;0.0 +22;2.2097121344377735;-0.11719422091117584;0.2279873078134626;-0.0023770517751713002;-0.11189594729811711;0.0230851555895672;0.00553118903924988;0.04839819971519953;-0.23801113403519117;0.10598261845841896;0.0;0.0 +23;2.208938543570736;-0.11522182227023188;0.22593263246426784;0.01092330278222169;-0.0915136987358271;0.06233988597169424;0.0044669305492021;0.043306237439660764;-0.2846557900705459;0.10368589187138462;0.0;0.0 +24;2.2094127170809115;-0.1143302874499675;0.2227779244747404;0.012155072575687799;-0.10922920069948824;0.021710157001176195;0.006256965523254033;0.05778282955905289;-0.264212711162102;0.10282286466566024;0.0;0.0 diff --git a/src/pandapipes/test/data/test_valve.csv b/src/pandapipes/test/data/test_valve.csv new file mode 100644 index 000000000..c2ef311a8 --- /dev/null +++ b/src/pandapipes/test/data/test_valve.csv @@ -0,0 +1,9 @@ +v;p +3.22745895;5.000000 +6.51741793;4.9080733 +0.000000;1.91490122 +-6.69851687;2.0077237 +0.000000;1.91490122 +4.17401625;1.84812247 +;4.9080733 +;2.0077237 \ No newline at end of file diff --git a/src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv b/src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv deleted file mode 100644 index b4357e527..000000000 --- a/src/pandapipes/test/pipeflow_internals/data/test_pressure_control.csv +++ /dev/null @@ -1,5 +0,0 @@ -v;p -3.04310;5.000000 -3.42763;25.57238 -;23.86160 -;20.00000 \ No newline at end of file diff --git a/src/pandapipes/test/pipeflow_internals/data/test_pump.csv b/src/pandapipes/test/pipeflow_internals/data/test_pump.csv deleted file mode 100644 index 1981afded..000000000 --- a/src/pandapipes/test/pipeflow_internals/data/test_pump.csv +++ /dev/null @@ -1,5 +0,0 @@ -v;p -0.63583577;5.000000 -0.31936598;4.99846063 -;10.80254845 -;10.80207844 \ No newline at end of file diff --git a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv b/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv deleted file mode 100644 index b69f06b0c..000000000 --- a/src/pandapipes/test/pipeflow_internals/data/test_time_series_results/res_pipe/v_mean_m_per_s.csv +++ /dev/null @@ -1,26 +0,0 @@ -;0;1;2;3;4;5;6;7;8;9;10;11 -0;2.2097121199437777;-0.1187172126059357;0.2305200609473057;0.027977683643822804;-0.12100792178250641;0.012579144288715316;0.006666476024910661;0.0649880810185337;-0.2750668845422708;0.10602751966095392;0.0;0.0 -1;2.2090875635230445;-0.11597953221715196;0.2266968659811206;0.06275140430459292;-0.10576363790563814;0.036252530634289126;0.0011995875626094055;0.0072098387858021695;-0.2857233449875407;0.10030855389121163;0.0;0.0 -2;2.208987703263464;-0.11418078334884152;0.2244270949238225;0.04400599890053014;-0.09186168857464194;0.05497694704959333;0.0033035940754304605;0.029464794207755052;-0.28654837231067454;0.10062557999831645;0.0;0.0 -3;2.2092219309727037;-0.11859736063809301;0.23059740740297752;0.057720315358643415;-0.11772233440089064;0.017757636927716813;0.0019408800869320508;0.013374931199335638;-0.25137040643872677;0.10328569434425638;0.0;0.0 -4;2.2091168414578237;-0.11856342011312337;0.23244294114356867;0.062000271290940656;-0.09499993867536993;0.05839255132582277;0.0026939022937595425;0.019484096015249808;-0.2799885932038806;0.10278010204402488;0.0;0.0 -5;2.209536478177894;-0.11663690518560754;0.22857738810193018;0.01381801525799009;-0.09800821778078017;0.04927761842716594;0.007708993284928578;0.07128241400981183;-0.24582017474860018;0.10502733799304798;0.0;0.0 -6;2.209825803552108;-0.11527897014510291;0.22657468541584747;0.06861368232907017;-0.09083062974780454;0.05712166195140167;0.0025402938028653566;0.022754093602042058;-0.2703878091501126;0.09894762618434472;0.0;0.0 -7;2.209249604193983;-0.11567354615042724;0.22518674252716808;0.015322568012011928;-0.11622331194904456;0.013499393849513819;0.005430480057782017;0.0506071297263766;-0.27734665669146796;0.10408483916809796;0.0;0.0 -8;2.208959694404101;-0.1186809336375867;0.23051318789316078;0.04898475009572856;-0.12034675640369352;0.013349022200163319;0.0018929466335890766;0.014030846921639917;-0.2577552066795672;0.10425449173575796;0.0;0.0 -9;2.209190780953666;-0.11625110188144516;0.22661459101051262;0.027967845063070484;-0.11258151121249016;0.02393840572043393;0.005442099389756372;0.05147183028027058;-0.281578553624211;0.10380895822447389;0.0;0.0 -10;2.209530880720217;-0.11660810240323194;0.22629531696342786;0.014218673582551133;-0.12327183134193964;0.0014006240019126537;0.004878882794228989;0.0448430972512992;-0.24386488452289745;0.10498033619443348;0.0;0.0 -11;2.209498243153096;-0.11609282568627366;0.22622519176069167;0.053255760215666026;-0.11357275917863552;0.02238763872870564;0.0007638564498839706;0.006428977884384235;-0.2808869052105081;0.10146125948396634;0.0;0.0 -12;2.2094908933502495;-0.11584523205468455;0.22585898553617723;0.07752666115058293;-0.11242802469084356;0.018622560767283414;0.0005972049215157149;9.423706258848696e-05;-0.2936707297286203;0.09830080092576843;0.0;0.0 -13;2.2091690161071855;-0.11743481070196315;0.22802196287616194;0.07911213282747465;-0.12166446214901816;0.007906618639860863;0.0006733587953156039;0.0033156840560115697;-0.2554204861333589;0.09957358146084028;0.0;0.0 -14;2.2096108749627223;-0.11672321807935004;0.22712331751684767;0.02250198917154833;-0.11683060462356343;0.014911528501309057;0.003841740361714585;0.03205016142617101;-0.28479085574876883;0.1046000802634528;0.0;0.0 -15;2.209464726439732;-0.11521209395560206;0.2251688698081611;0.06654988033942066;-0.10664701310430269;0.0332812723266791;0.0027919323815805974;0.022534048293221698;-0.24766154864032197;0.09914221482130126;0.0;0.0 -16;2.209559722129226;-0.11401544022095633;0.2238134104879399;0.011099938666717879;-0.09571915501171091;0.05173593327817949;0.007711633697049081;0.07114434079013199;-0.24047219572485012;0.10282458978838704;0.0;0.0 -17;2.2095871868374393;-0.11723469680910226;0.2284576570311625;0.037911150729522;-0.11281741026904779;0.021850387247313474;0.0015381562108389701;0.013389930524942528;-0.25632630752000196;0.10393310763396402;0.0;0.0 -18;2.2093033200303203;-0.11676779411487592;0.22735031574515974;0.04481742938966793;-0.11527986053417738;0.018071440092238156;0.003770423999247541;0.036502048034013246;-0.2681917375491545;0.1029047308207538;0.0;0.0 -19;2.2088684490883077;-0.11641168515655931;0.22858515341567553;0.021917852719524955;-0.0924519281817453;0.05946475951804997;0.005072882617790597;0.04473243772880364;-0.29844959045381714;0.10435755084737774;0.0;0.0 -20;2.2092796166234723;-0.11758019947175091;0.22926977331452703;0.07425727935286153;-0.11103722939100136;0.02896558557716178;0.000583195450738927;0.003938803942762359;-0.28075903590583806;0.10036553843503926;0.0;0.0 -21;2.2093380953041257;-0.11586322398343052;0.22630044455042775;0.060865101486132556;-0.10781413535491557;0.03159951527884175;0.0002156040417702343;0.0005480718794359518;-0.25214553702266995;0.10041944278478798;0.0;0.0 -22;2.209711596346974;-0.11700951908296942;0.228104265744014;-0.002309498046526137;-0.1119617889893112;0.02308515571695402;0.005531189738821052;0.04839820583662835;-0.23801105045403892;0.10605013153410736;0.0;0.0 -23;2.2089379692799893;-0.11503658660678795;0.2260607791080651;0.010980187819213505;-0.09158583753201954;0.06233988660569434;0.0044669304297753065;0.043306236281867694;-0.2846557030405137;0.10374273042140603;0.0;0.0 -24;2.2094121387276946;-0.11414168390729929;0.22290842356933993;0.012212972285832624;-0.10930266293713187;0.02171015713894331;0.006256965347797294;0.057782827938737125;-0.2642126243445273;0.10288071769825491;0.0;0.0 diff --git a/src/pandapipes/test/pipeflow_internals/data/test_valve.csv b/src/pandapipes/test/pipeflow_internals/data/test_valve.csv deleted file mode 100644 index af288c717..000000000 --- a/src/pandapipes/test/pipeflow_internals/data/test_valve.csv +++ /dev/null @@ -1,9 +0,0 @@ -v;p -3.34756119;5.000000 -7.18394314;4.90465232 -0.000000;1.7347882 --7.41932376;1.83710656 -0.000000;1.7347882 -4.39032284;1.66082228 -;4.90465232 -;1.83710656 \ No newline at end of file From dff95f7daedc95eaa5731e08a037f65476b4228f Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:09:18 +0100 Subject: [PATCH 081/237] result changes due to norm state --- .../test/api/test_components/test_ext_grid.py | 6 +- .../test/stanet_comparison/test_gas_stanet.py | 68 +++++++++---------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index 45a125508..b00538de2 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -102,7 +102,7 @@ def test_t_type_single_pipe(use_numba): j0 = pandapipes.create_junction(net2, pn_bar=5, tfluid_k=283) j1 = pandapipes.create_junction(net2, pn_bar=5, tfluid_k=283) pandapipes.create_ext_grid(net2, j0, 5, 645, type="p") - pandapipes.create_ext_grid(net2, j1, 100, 323.15, type="t") + pandapipes.create_ext_grid(net2, j1, 100, 327.765863, type="t") pandapipes.create_sink(net2, j1, 1) pandapipes.create_pipe_from_parameters(net2, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, @@ -273,7 +273,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.create_sink(net, j3, 1) pandapipes.create_sink(net, j4, 1) pandapipes.create_ext_grid(net, j0, 5, 645, type="t") - pandapipes.create_ext_grid(net, j4, 5, 378.83472, type="t") + pandapipes.create_ext_grid(net, j4, 5, 382.485897, type="t") pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, alpha_w_per_m2k=5) @@ -344,7 +344,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.create_sink(net, j3, 1) pandapipes.create_sink(net, j4, 1) pandapipes.create_ext_grid(net, j2, 5, 645, type="t") - pandapipes.create_ext_grid(net, j4, 5, 378.83472, type="t") + pandapipes.create_ext_grid(net, j4, 5, 382.485897, type="t") pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, diameter_m=d, k_mm=.1, sections=5, alpha_w_per_m2k=5) diff --git a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py index af87f95ac..b283552b6 100644 --- a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py @@ -32,8 +32,8 @@ def test_case_3parallel_n(use_numba, log_results=False): """ net = nw.gas_3parallel(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # parallel_PC @@ -49,8 +49,8 @@ def test_case_combined_3parallel_pc(use_numba, log_results=False): net = nw.gas_3parallel(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # ---------- TEST AREA: meshed networks ---------- @@ -66,8 +66,8 @@ def test_case_square_n(use_numba, log_results=False): """ net = nw.gas_meshed_square(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # square_PC @@ -108,7 +108,7 @@ def test_case_meshed_delta_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_pumps(use_numba, log_results=False): """ - + # TODO: check the big differences in v :param log_results: :type log_results: :return: @@ -126,8 +126,8 @@ def test_case_meshed_pumps(use_numba, log_results=False): def test_case_meshed_2valves_n(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.001) - assert np.all(v_diff_abs < 0.001) + assert np.all(p_diff < 10 ** -3) + assert np.all(v_diff_abs < 10 ** -3) # two_valves_PC @@ -136,8 +136,8 @@ def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.001) - assert np.all(v_diff_abs < 0.001) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -3) # ---------- TEST AREA: one pipe ---------- @@ -153,8 +153,8 @@ def test_case_one_pipe1_n(use_numba, log_results=False): """ net = nw.gas_one_pipe1(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # pipe_1_PC @@ -170,8 +170,8 @@ def test_case_one_pipe1_pc(use_numba, log_results=False): net = nw.gas_one_pipe1(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # pipe_2_N @@ -203,8 +203,8 @@ def test_case_one_pipe2_pc(use_numba, log_results=False): net = nw.gas_one_pipe2(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # ---------- TEST AREA: strand net ---------- @@ -220,8 +220,8 @@ def test_case_strand_2pipes_n(use_numba, log_results=False): """ net = nw.gas_strand_2pipes(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # two_pipes_PC @@ -237,9 +237,8 @@ def test_case_strand_2pipes_pc(use_numba, log_results=False): net = nw.gas_strand_2pipes(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) - + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # pump_N @pytest.mark.parametrize("use_numba", [True, False]) @@ -271,8 +270,8 @@ def test_case_tcross1_n(use_numba, log_results=False): """ net = nw.gas_tcross1(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # t-cross1_PC @@ -288,8 +287,8 @@ def test_case_tcross1_pc(use_numba, log_results=False): net = nw.gas_tcross1(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # t-cross2_N @@ -304,8 +303,8 @@ def test_case_tcross2_n(use_numba, log_results=False): """ net = nw.gas_tcross2(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # t-cross2_PC @@ -321,8 +320,8 @@ def test_case_tcross2_pc(use_numba, log_results=False): net = nw.gas_tcross2(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # ---------- TEST AREA: two pressure junctions ---------- @@ -338,8 +337,8 @@ def test_case_2eg_hnet_n(use_numba, log_results=False): """ net = nw.gas_2eg_hnet(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # H-net_PC @@ -355,9 +354,8 @@ def test_case_2eg_hnet_pc(use_numba, log_results=False): net = nw.gas_2eg_hnet(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) - + assert np.all(p_diff < 10 ** -4) + assert np.all(v_diff_abs < 10 ** -2) # # ---------------------------------------- # def test_case12(log_results=False): From 7ea93b4f1f388db85441c50a6ab1eee57a0cd324 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 12:10:30 +0100 Subject: [PATCH 082/237] imporve readability and consider changes from v to m --- src/pandapipes/pf/derivative_toolbox.py | 115 +++++++-------- src/pandapipes/pf/derivative_toolbox_numba.py | 131 ++++++++---------- 2 files changed, 121 insertions(+), 125 deletions(-) diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index bbfd7dadb..defe6427c 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -7,81 +7,79 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE -from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, RHO, PL, AREA, \ - VINIT, TOUTINIT, FROM_NODE +from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ + MINIT, TOUTINIT, FROM_NODE from pandapipes.idx_node import HEIGHT, PINIT, PAMB, TINIT as TINIT_NODE def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference): - v_init_abs = np.abs(branch_pit[:, VINIT]) - v_init2 = v_init_abs * branch_pit[:, VINIT] - lambda_term = np.divide(branch_pit[:, LENGTH] * branch_pit[:, LAMBDA], branch_pit[:, D]) \ - + branch_pit[:, LC] - const_p_term = np.divide(branch_pit[:, RHO], P_CONVERSION * 2) - df_dv = const_p_term * (2 * v_init_abs * lambda_term + der_lambda - * np.divide(branch_pit[:, LENGTH], branch_pit[:, D]) * v_init2) - load_vec = p_init_i_abs - p_init_i1_abs + branch_pit[:, PL] \ - + const_p_term * (GRAVITATION_CONSTANT * 2 * height_difference - - v_init2 * lambda_term) - mass_flow_dv = branch_pit[:, RHO] * branch_pit[:, AREA] - df_dv_nodes = mass_flow_dv - load_vec_nodes = mass_flow_dv * branch_pit[:, VINIT] + height_difference, rho, rho_n): + m_init_abs = np.abs(branch_pit[:, MINIT]) + m_init2 = m_init_abs * branch_pit[:, MINIT] + p_diff = p_init_i_abs - p_init_i1_abs + const_height = rho * GRAVITATION_CONSTANT * height_difference / P_CONVERSION + friction_term = np.divide(branch_pit[:, LENGTH] * branch_pit[:, LAMBDA], branch_pit[:, D]) + branch_pit[:, LC] + const_term = np.divide(1, branch_pit[:, AREA] ** 2 * rho_n * P_CONVERSION * 2) + + df_dm = const_term * (2 * m_init_abs * friction_term + der_lambda + * np.divide(branch_pit[:, LENGTH], branch_pit[:, D]) * m_init2) + + load_vec = p_diff + branch_pit[:, PL] + const_height - const_term * m_init2 * friction_term + df_dp = np.ones_like(der_lambda) * (-1) df_dp1 = np.ones_like(der_lambda) - return load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 + + df_dm_nodes = np.ones_like(der_lambda) + + load_vec_nodes = branch_pit[:, MINIT] + + return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 def derivatives_hydraulic_comp_np(node_pit, branch_pit, lambda_, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference, comp_fact, der_comp, der_comp1): + height_difference, comp_fact, der_comp, der_comp1, rho, rho_n): # Formulas for gas pressure loss according to laminar version - v_init_abs = np.abs(branch_pit[:, VINIT]) - v_init2 = branch_pit[:, VINIT] * v_init_abs + m_init_abs = np.abs(branch_pit[:, MINIT]) + m_init2 = branch_pit[:, MINIT] * m_init_abs p_diff = p_init_i_abs - p_init_i1_abs p_sum = p_init_i_abs + p_init_i1_abs p_sum_div = np.divide(1, p_sum) from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) tm = (node_pit[from_nodes, TINIT_NODE] + branch_pit[:, TOUTINIT]) / 2 - const_lambda = np.divide(NORMAL_PRESSURE * branch_pit[:, RHO] * tm, - NORMAL_TEMPERATURE * P_CONVERSION) - const_height = np.divide( - branch_pit[:, RHO] * NORMAL_TEMPERATURE * GRAVITATION_CONSTANT * height_difference, - 2 * NORMAL_PRESSURE * tm * P_CONVERSION) + const_height = rho * GRAVITATION_CONSTANT * height_difference / P_CONVERSION friction_term = np.divide(lambda_ * branch_pit[:, LENGTH], branch_pit[:, D]) + branch_pit[:, LC] + normal_term = np.divide(NORMAL_PRESSURE, NORMAL_TEMPERATURE * P_CONVERSION * rho_n * branch_pit[:, AREA] ** 2) - load_vec = p_diff + branch_pit[:, PL] + const_height * p_sum \ - - const_lambda * comp_fact * v_init2 * friction_term * p_sum_div + const_term_p = normal_term * m_init2 * friction_term * tm + df_dp = -1. + const_term_p * p_sum_div * (der_comp - comp_fact * p_sum_div) + df_dp1 = 1. + const_term_p * p_sum_div * (der_comp1 - comp_fact * p_sum_div) - p_deriv = const_lambda * v_init2 * friction_term * p_sum_div - df_dp = -1. + p_deriv * (der_comp - comp_fact * p_sum_div) + const_height - df_dp1 = 1. + p_deriv * (der_comp1 - comp_fact * p_sum_div) + const_height + const_term_m = normal_term * p_sum_div * tm * comp_fact + df_dm = const_term_m * (2 * m_init_abs * friction_term + + np.divide(der_lambda * branch_pit[:, LENGTH] * m_init2, branch_pit[:, D])) - df_dv = np.divide(2 * const_lambda * comp_fact, p_sum) * v_init_abs * friction_term \ - + np.divide(const_lambda * comp_fact * der_lambda * branch_pit[:, LENGTH] * v_init2, - p_sum * branch_pit[:, D]) - mass_flow_dv = branch_pit[:, RHO] * branch_pit[:, AREA] - df_dv_nodes = mass_flow_dv - load_vec_nodes = mass_flow_dv * branch_pit[:, VINIT] + load_vec = p_diff + branch_pit[:, PL] + const_height \ + - normal_term * comp_fact * m_init2 * friction_term * p_sum_div * tm - return load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 + df_dm_nodes = np.ones_like(lambda_) + load_vec_nodes = branch_pit[:, MINIT] + return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 -def calc_lambda_nikuradse_incomp_np(v, d, k, eta, rho): - v_abs = np.abs(v) - v_abs[v_abs < 1e-6] = 1e-6 - re = np.divide(rho * v_abs * d, eta) - lambda_laminar = np.zeros_like(v) - lambda_laminar[v != 0] = 64 / re[v != 0] +def calc_lambda_nikuradse_incomp_np(m, d, k, eta, area): + m_abs = np.abs(m) + re = np.divide(m_abs * d, eta * area) + lambda_laminar = np.zeros_like(m) + lambda_laminar[~np.isclose(re, 0)] = 64 / re[~np.isclose(re, 0)] lambda_nikuradse = np.divide(1, (-2 * np.log10(k / (3.71 * d))) ** 2) return re, lambda_laminar, lambda_nikuradse -def calc_lambda_nikuradse_comp_np(v, d, k, eta, rho): - v_abs = np.abs(v) - v_abs[v_abs < 1e-6] = 1e-6 - re = np.divide(rho * v_abs * d, eta) - lambda_laminar = np.zeros_like(v) - lambda_laminar[v != 0] = 64 / re[v != 0] +def calc_lambda_nikuradse_comp_np(m, d, k, eta, area): + m_abs = np.abs(m) + re = np.divide(m_abs * d, eta * area) + lambda_laminar = np.zeros_like(m) + lambda_laminar[~np.isclose(re, 0)] = 64 / re[~np.isclose(re, 0)] lambda_nikuradse = np.divide(1, (2 * np.log10(d / k) + 1.14) ** 2) return re, lambda_laminar, lambda_nikuradse @@ -110,7 +108,7 @@ def calc_medium_pressure_with_derivative_np(p_init_i_abs, p_init_i1_abs): return p_m, der_p_m, der_p_m1 - +# TODO: check NR colebrook def colebrook_np(re, d, k, lambda_nikuradse, dummy, max_iter): """ @@ -133,15 +131,22 @@ def colebrook_np(re, d, k, lambda_nikuradse, dummy, max_iter): converged = False error_lambda = [] niter = 0 - + mask = ~np.isclose(re, 0) + f = np.zeros_like(lambda_cb) + df = np.zeros_like(lambda_cb) + x = np.zeros_like(lambda_cb) + re_nz = re[mask] + k_nz = k[mask] + d_nz = d[mask] # Inner Newton-loop for calculation of lambda while not converged and niter < max_iter: - f = lambda_cb ** (-1 / 2) + 2 * np.log10(2.51 / (re * np.sqrt(lambda_cb)) + k / (3.71 * d)) - df_dlambda_cb = (-1 / 2 * lambda_cb ** (-3 / 2)) - (2.51 / re) * lambda_cb ** (-3 / 2) \ - / (np.log(10) * 2.51 / (re * np.sqrt(lambda_cb) + k / (3.71 * d))) + f[mask] = lambda_cb[mask] ** (-1 / 2) + 2 * np.log10(2.51 / (re_nz * np.sqrt(lambda_cb[mask])) + k_nz / (3.71 * d_nz)) + + df[mask]= -1 / 2 * lambda_cb[mask] ** (-3 / 2) - (2.51 / re_nz) * lambda_cb[mask] ** (-3 / 2) \ + / (np.log(10) * (2.51 / (re_nz * np.sqrt(lambda_cb[mask])) + k_nz / (3.71 * d_nz))) - x = - f / df_dlambda_cb + x[mask] = - f[mask] / df[mask] lambda_cb_old = lambda_cb lambda_cb = lambda_cb + x diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 3e125a114..e0058117b 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -3,8 +3,8 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE -from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, RHO, PL, AREA, \ - VINIT, FROM_NODE, TO_NODE +from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ + MINIT, FROM_NODE, TO_NODE from pandapipes.idx_node import HEIGHT, PAMB, PINIT, TINIT as TINIT_NODE try: @@ -15,53 +15,54 @@ from numpy import int32, float64, int64 -@jit((float64[:, :], float64[:], float64[:], float64[:], float64[:]), nopython=True, cache=False) +@jit((float64[:, :], float64[:], float64[:], float64[:], float64[:], float64[:], float64[:]), nopython=True, cache=False) def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference): + height_difference, rho, rho_n): le = der_lambda.shape[0] load_vec = np.zeros_like(der_lambda) - df_dv = np.zeros_like(der_lambda) + df_dm = np.zeros_like(der_lambda) df_dp = np.ones_like(der_lambda) * (-1) df_dp1 = np.ones_like(der_lambda) load_vec_nodes = np.zeros_like(der_lambda) - df_dv_nodes = np.zeros_like(der_lambda) + df_dm_nodes = np.ones_like(der_lambda) for i in range(le): - v_init_abs = np.abs(branch_pit[i][VINIT]) - v_init2 = v_init_abs * branch_pit[i][VINIT] - lambda_term = np.divide(branch_pit[i][LENGTH] * branch_pit[i][LAMBDA], branch_pit[i][D]) \ + m_init_abs = np.abs(branch_pit[i][MINIT]) + m_init2 = m_init_abs * branch_pit[i][MINIT] + p_diff = p_init_i_abs[i] - p_init_i1_abs[i] + const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION + friction_term = np.divide(branch_pit[i][LENGTH] * branch_pit[i][LAMBDA], branch_pit[i][D]) \ + branch_pit[i][LC] - const_p_term = np.divide(branch_pit[i][RHO], P_CONVERSION * 2) - df_dv[i] = const_p_term * (2 * v_init_abs * lambda_term + der_lambda[i] - * np.divide(branch_pit[i][LENGTH], branch_pit[i][D]) * v_init2) - load_vec[i] = p_init_i_abs[i] - p_init_i1_abs[i] + branch_pit[i][PL] \ - + const_p_term * (GRAVITATION_CONSTANT * 2 * height_difference[i] - - v_init2 * lambda_term) - mass_flow_dv = branch_pit[i][RHO] * branch_pit[i][AREA] - df_dv_nodes[i] = mass_flow_dv - load_vec_nodes[i] = mass_flow_dv * branch_pit[i][VINIT] - return load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 + const_term = np.divide(1, branch_pit[i][AREA] ** 2 * rho_n[i] * P_CONVERSION * 2) + + df_dm[i] = const_term * (2 * m_init_abs * friction_term + der_lambda[i] + * np.divide(branch_pit[i][LENGTH], branch_pit[i][D]) * m_init2) + + load_vec[i] = p_diff + branch_pit[i][PL] + const_height - const_term * m_init2 * friction_term + + load_vec_nodes[i] = branch_pit[i][MINIT] + return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 @jit((float64[:, :], float64[:, :], float64[:], float64[:], float64[:], float64[:], float64[:], float64[:], - float64[:], float64[:]), nopython=True, cache=False) + float64[:], float64[:], float64[:], float64[:]), nopython=True, cache=False) def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference, comp_fact, der_comp, der_comp1): + height_difference, comp_fact, der_comp, der_comp1, rho, rho_n): le = lambda_.shape[0] load_vec = np.zeros_like(lambda_) - df_dv = np.zeros_like(lambda_) + df_dm = np.zeros_like(lambda_) df_dp = np.zeros_like(lambda_) df_dp1 = np.zeros_like(lambda_) * (-1) load_vec_nodes = np.zeros_like(der_lambda) - df_dv_nodes = np.zeros_like(der_lambda) + df_dm_nodes = np.ones_like(der_lambda) from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) to_nodes = branch_pit[:, TO_NODE].astype(np.int32) # Formulas for gas pressure loss according to laminar version for i in range(le): # compressibility settings - v_init_abs = np.abs(branch_pit[i][VINIT]) - v_init2 = branch_pit[i][VINIT] * v_init_abs + m_init_abs = np.abs(branch_pit[i][MINIT]) + m_init2 = branch_pit[i][MINIT] * m_init_abs p_diff = p_init_i_abs[i] - p_init_i1_abs[i] p_sum = p_init_i_abs[i] + p_init_i1_abs[i] p_sum_div = np.divide(1, p_sum) @@ -69,59 +70,49 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, tn = to_nodes[i] tm = (node_pit[fn, TINIT_NODE] + node_pit[tn, TINIT_NODE]) / 2 - const_lambda = np.divide(NORMAL_PRESSURE * branch_pit[i][RHO] * tm, - NORMAL_TEMPERATURE * P_CONVERSION) - const_height = np.divide( - branch_pit[i][RHO] * NORMAL_TEMPERATURE * GRAVITATION_CONSTANT * height_difference[i], - 2 * NORMAL_PRESSURE * tm * P_CONVERSION) - friction_term = np.divide(lambda_[i] * branch_pit[i][LENGTH], - branch_pit[i][D]) + branch_pit[i][LC] + const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION + friction_term = np.divide(lambda_[i] * branch_pit[i][LENGTH], branch_pit[i][D]) + \ + branch_pit[i][LC] + normal_term = np.divide(NORMAL_PRESSURE, NORMAL_TEMPERATURE * P_CONVERSION * rho_n[i] * + branch_pit[i][AREA] ** 2) + + load_vec[i] = p_diff + branch_pit[i][PL] + const_height \ + - normal_term * comp_fact[i] * m_init2 * friction_term * p_sum_div * tm - load_vec[i] = p_diff + branch_pit[i][PL] + const_height * p_sum \ - - const_lambda * comp_fact[i] * v_init2 * friction_term * p_sum_div + const_term = normal_term * m_init2 * friction_term * tm + df_dp[i] = -1. + const_term * p_sum_div * (der_comp[i] - comp_fact[i] * p_sum_div) + df_dp1[i] = 1. + const_term * p_sum_div * (der_comp1[i] - comp_fact[i] * p_sum_div) - p_deriv = const_lambda * v_init2 * friction_term * p_sum_div - df_dp[i] = -1. + p_deriv * (der_comp[i] - comp_fact[i] * p_sum_div) + const_height - df_dp1[i] = 1. + p_deriv * (der_comp1[i] - comp_fact[i] * p_sum_div) + const_height + df_dm[i] = normal_term * comp_fact[i] * p_sum_div * tm * (2 * m_init_abs * friction_term \ + + np.divide(der_lambda[i] * branch_pit[i][LENGTH] * m_init2, branch_pit[i][D])) - df_dv[i] = np.divide(2 * const_lambda * comp_fact[i], p_sum) * v_init_abs * friction_term\ - + np.divide(const_lambda * comp_fact[i] * der_lambda[i] * branch_pit[i][LENGTH] - * v_init2, p_sum * branch_pit[i][D]) - mass_flow_dv = branch_pit[i][RHO] * branch_pit[i][AREA] - df_dv_nodes[i] = mass_flow_dv - load_vec_nodes[i] = mass_flow_dv * branch_pit[i][VINIT] - return load_vec, load_vec_nodes, df_dv, df_dv_nodes, df_dp, df_dp1 + load_vec_nodes[i] = branch_pit[i][MINIT] + return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 @jit((float64[:], float64[:], float64[:], float64[:], float64[:]), nopython=True) -def calc_lambda_nikuradse_incomp_numba(v, d, k, eta, rho): - lambda_nikuradse = np.empty_like(v) - lambda_laminar = np.zeros_like(v) - re = np.empty_like(v) - v_abs = np.abs(v) - for i in range(v.shape[0]): - if v_abs[i] < 1e-6: - re[i] = np.divide(rho[i] * 1e-6 * d[i], eta[i]) - else: - re[i] = np.divide(rho[i] * v_abs[i] * d[i], eta[i]) - if v[i] != 0: +def calc_lambda_nikuradse_incomp_numba(m, d, k, eta, area): + lambda_nikuradse = np.empty_like(m) + lambda_laminar = np.zeros_like(m) + re = np.empty_like(m) + m_abs = np.abs(m) + for i in range(m.shape[0]): + re[i] = np.divide(m_abs[i] * d[i], eta[i] * area[i]) + if re[i] != 0: lambda_laminar[i] = 64 / re[i] lambda_nikuradse[i] = np.power(-2 * np.log10(k[i] / (3.71 * d[i])), -2) return re, lambda_laminar, lambda_nikuradse @jit((float64[:], float64[:], float64[:], float64[:], float64[:]), nopython=True) -def calc_lambda_nikuradse_comp_numba(v, d, k, eta, rho): - lambda_nikuradse = np.empty_like(v) - lambda_laminar = np.zeros_like(v) - re = np.empty_like(v) - for i in range(len(v)): - v_abs = np.abs(v[i]) - if v_abs < 1e-6: - re[i] = np.divide(rho[i] * 1e-6 * d[i], eta[i]) - else: - re[i] = np.divide(rho[i] * v_abs * d[i], eta[i]) - if v[i] != 0: +def calc_lambda_nikuradse_comp_numba(m, d, k, eta, area): + lambda_nikuradse = np.empty_like(m) + lambda_laminar = np.zeros_like(m) + re = np.empty_like(m) + for i in range(len(m)): + m_abs = np.abs(m[i]) + re[i] = np.divide(m_abs * d[i], eta[i] * area[i]) + if re[i] != 0: lambda_laminar[i] = np.divide(64, re[i]) lambda_nikuradse[i] = np.divide(1, (2 * np.log10(np.divide(d[i], k[i])) + 1.14) ** 2) return re, lambda_laminar, lambda_nikuradse @@ -145,18 +136,18 @@ def calc_medium_pressure_with_derivative_numba(p_init_i_abs, p_init_i1_abs): + 2 * p_init_i1_abs[i] * diff_p_cub) * diff_p_sq_div ** 2 * val return p_m, der_p_m, der_p_m1 - +# TODO: check NR colebrook @jit((float64[:], float64[:], float64[:], float64[:], float64[:], int64), nopython=True) def colebrook_numba(re, d, k, lambda_nikuradse, dummy, max_iter): lambda_cb = lambda_nikuradse.copy() - lambda_cb_old = np.empty_like(lambda_nikuradse) + lambda_cb_old = lambda_nikuradse.copy() converged = False niter = 0 - factor = np.log(10) * 2.51 # Inner Newton-loop for calculation of lambda while not converged and niter < max_iter: for i in range(len(lambda_cb)): + if np.isclose(re[i],0): continue sqt = np.sqrt(lambda_cb[i]) add_val = np.divide(k[i], (3.71 * d[i])) sqt_div = np.divide(1, sqt) @@ -165,7 +156,7 @@ def colebrook_numba(re, d, k, lambda_nikuradse, dummy, max_iter): f = sqt_div + 2 * np.log10(2.51 * re_div * sqt_div + add_val) df_dlambda_cb = - 0.5 * sqt_div3 - 2.51 * re_div * sqt_div3 * np.divide( - re[i] * sqt + add_val, factor) + 1, np.log(10) * (2.51 * re_div * sqt_div + add_val)) x = - f / df_dlambda_cb lambda_cb_old[i] = lambda_cb[i] From 56b6e5e2ec865c04fdfd94ce26a8312f7e5bc686 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:15:46 +0100 Subject: [PATCH 083/237] required for single values --- src/pandapipes/properties/fluids.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pandapipes/properties/fluids.py b/src/pandapipes/properties/fluids.py index 763d7c22d..c97a89604 100644 --- a/src/pandapipes/properties/fluids.py +++ b/src/pandapipes/properties/fluids.py @@ -330,7 +330,10 @@ def get_at_value(self, *args): if self.warn_dependent_variables: logger.warning('Constant property received several input variables, although it is' 'independent of these') - output = np.array([self.value]) * np.ones(len(args[0])) + if not hasattr(args[0], "__len__"): + output = np.array([self.value]) + else: + output = np.array([self.value]) * np.ones(len(args[0])) else: output = np.array([self.value]) return output From 0057c4590564f5c086cff72e06e00ec52ced82f4 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:18:34 +0100 Subject: [PATCH 084/237] tol_v to tol_m --- .../api/test_components/test_circ_pump_mass.py | 2 +- .../test_components/test_circ_pump_pressure.py | 2 +- .../test/api/test_components/test_ext_grid.py | 10 +++++----- .../api/test_components/test_heat_exchanger.py | 2 +- .../api/test_components/test_pipe_results.py | 4 ++-- .../test/api/test_components/test_pump.py | 8 ++++---- .../pipeflow_openmodelica_comparison.py | 2 +- .../test/pipeflow_internals/test_inservice.py | 16 ++++++++-------- .../test/pipeflow_internals/test_options.py | 4 ++-- .../test_pipeflow_analytic_comparison.py | 16 ++++++++-------- .../pipeflow_internals/test_pipeflow_modes.py | 2 +- .../pipeflow_stanet_comparison.py | 2 +- tutorials/temperature_calculation.ipynb | 2 +- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index c41f8f4a4..ae30750cc 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -36,7 +36,7 @@ def test_circulation_pump_constant_mass(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_mass.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index 77536174d..c85469c5a 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -37,7 +37,7 @@ def test_circulation_pump_constant_pressure(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index b00538de2..082c560b6 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -60,7 +60,7 @@ def test_p_type(use_numba): pandapipes.create_sink(net, 1, mdot_kg_per_s=1) pandapipes.create_fluid_from_lib(net, name="water") pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, + transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "ext_grid_p.csv"), @@ -148,7 +148,7 @@ def test_t_type_tee(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp = net.res_junction.t_k.values @@ -172,7 +172,7 @@ def test_t_type_tee(use_numba): pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, + transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -216,7 +216,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp = net.res_junction.t_k.values @@ -245,7 +245,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", iter=3, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode="all", use_numba=use_numba) temp2 = net2.res_junction.t_k.values diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index a2e7b562c..bd1483200 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -31,7 +31,7 @@ def test_heat_exchanger(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "heat_exchanger_test.csv"), sep=';', header=0, keep_default_na=False) diff --git a/src/pandapipes/test/api/test_components/test_pipe_results.py b/src/pandapipes/test/api/test_components/test_pipe_results.py index 6ba8d0cb6..0c19372b0 100644 --- a/src/pandapipes/test/api/test_components/test_pipe_results.py +++ b/src/pandapipes/test/api/test_components/test_pipe_results.py @@ -38,7 +38,7 @@ def test_pipe_velocity_results(use_numba): compressibility=1, der_compressibility=0, density=0.82752 )) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_v=1e-5, + transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba) v_1_sec_from = net.res_pipe.v_from_m_per_s @@ -61,7 +61,7 @@ def test_pipe_velocity_results(use_numba): compressibility=1, der_compressibility=0, density=0.82752 )) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_v=1e-5, + transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba) v_n_sec_from = net.res_pipe.v_from_m_per_s diff --git a/src/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py index 4202ff231..d59b57328 100644 --- a/src/pandapipes/test/api/test_components/test_pump.py +++ b/src/pandapipes/test/api/test_components/test_pump.py @@ -79,7 +79,7 @@ def test_pump_from_regression_parameteres(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_pump.csv"), sep=';') @@ -117,7 +117,7 @@ def test_pump_from_std_type(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_pump.csv"), sep=';') @@ -155,7 +155,7 @@ def test_pump_bypass_on_reverse_flow(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) assert net.res_pump.deltap_bar.isin([0]).all() assert np.isclose(net.res_junction.loc[1, "p_bar"], net.res_junction.loc[2, "p_bar"]) @@ -185,7 +185,7 @@ def test_pump_bypass_high_vdot(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=30, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", - tol_p=1e-4, tol_v=1e-4, use_numba=use_numba) + tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) assert net.res_pump.deltap_bar.isin([0]).all() assert np.isclose(net.res_junction.loc[1, "p_bar"], net.res_junction.loc[2, "p_bar"]) diff --git a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py index 0fe9eb95d..53b830f39 100644 --- a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py +++ b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py @@ -40,7 +40,7 @@ def pipeflow_openmodelica_comparison(net, log_results=True, friction_model='cole :return: p_diff, v_diff_abs :rtype: one-dimensional ndarray with axis labels """ - pp.pipeflow(net, stop_condition="tol", iter=100, tol_p=1e-7, tol_v=1e-7, + pp.pipeflow(net, stop_condition="tol", iter=100, tol_p=1e-7, tol_m=1e-7, friction_model=friction_model, mode=mode, use_numba=use_numba, only_update_hydraulic_matrix=only_update_hydraulic_matrix) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index dc8b69e37..32d06670d 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -160,7 +160,7 @@ def test_inservice_gas(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "lgas") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_pipe.loc[~net.pipe.in_service, :].values)) @@ -193,7 +193,7 @@ def test_inservice_water(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_pipe.loc[~net.pipe.in_service, :].values)) @@ -263,7 +263,7 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) pandapipes.create_junction(net, 1., 293.15) @@ -276,7 +276,7 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): pandapipes.create_sink(net, j, 0.1) - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) active_branches = get_lookup(net, "branch", "active_hydraulics") @@ -291,7 +291,7 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[[7, 8, 10, 11]].values)) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=False) @@ -611,19 +611,19 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): ex2 = pandapipes.create_ext_grid(net, junction=3, p_bar=1) with pytest.raises(PipeflowNotConverged): net.ext_grid.at[ex2, 'in_service'] = False - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged net.ext_grid.at[ex1, 'in_service'] = False net.ext_grid.at[ex2, 'in_service'] = True - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert not np.all(np.isnan(net.res_junction.p_bar.values)) assert net.converged with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, mode='all', iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index 3765a32df..a5e0ce893 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -52,11 +52,11 @@ def test_set_user_pf_options(create_test_net, use_numba): # see if user arguments overrule user_pf_options, but other user_pf_options still have the # priority - pandapipes.pf.pipeflow_setup.set_user_pf_options(net, reset=True, tol_p=1e-6, tol_v=1e-6) + pandapipes.pf.pipeflow_setup.set_user_pf_options(net, reset=True, tol_p=1e-6, tol_m=1e-6) pandapipes.pipeflow(net, tol_p=1e-8, **necessary_options) assert net.user_pf_options['tol_p'] == 1e-6 assert net._options['tol_p'] == 1e-8 - assert net._options['tol_v'] == 1e-6 + assert net._options['tol_m'] == 1e-6 if __name__ == '__main__': diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 22b7a138a..10eddc0d9 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -36,7 +36,7 @@ def test_gas_internal_nodes(use_numba): compressibility=1, der_compressibility=0, density=0.82752 )) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, + transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) pipe_results = Pipe.get_internal_results(net, [0]) @@ -91,7 +91,7 @@ def test_temperature_internal_nodes_single_pipe(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) pipe_results = Pipe.get_internal_results(net, [0]) @@ -143,7 +143,7 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), sep=';', header=0, keep_default_na=False) @@ -183,7 +183,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), sep=';', header=0, keep_default_na=False) @@ -223,7 +223,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), sep=';', header=0, keep_default_na=False) @@ -263,7 +263,7 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), sep=';', header=0, keep_default_na=False) @@ -305,7 +305,7 @@ def test_temperature_internal_nodes_masche_1load(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_an.csv"), sep=';', header=0, keep_default_na=False) @@ -344,7 +344,7 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_v=1e-4, use_numba=use_numba) + tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_direction_an.csv"), diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index 6bdb14f87..a6a7487f0 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -43,7 +43,7 @@ def test_hydraulic_only(simple_test_net, use_numba): """ net = copy.deepcopy(simple_test_net) pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_v=1e-4, + transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "hydraulics.csv"), sep=';', header=0, diff --git a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py index 451d9c3af..56583d25d 100644 --- a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py +++ b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py @@ -33,7 +33,7 @@ def pipeflow_stanet_comparison(net, log_results=True, friction_model='nikuradse' :rtype: """ pandapipes.pipeflow(net, mode='hydraulics', stop_condition="tol", iter=100, tol_p=1e-7, - tol_v=1e-7, friction_model=friction_model, + tol_m=1e-7, friction_model=friction_model, only_update_hydraulic_matrix=only_update_hydraulic_matrix, **kwargs) p_stanet = net.junction.p_stanet diff --git a/tutorials/temperature_calculation.ipynb b/tutorials/temperature_calculation.ipynb index f5e24e463..b57c8c33a 100644 --- a/tutorials/temperature_calculation.ipynb +++ b/tutorials/temperature_calculation.ipynb @@ -236,4 +236,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} From d3f2fc949c285c857c25d6cf399ea63115772fdd Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:18:51 +0100 Subject: [PATCH 085/237] tol_v to tol_m --- src/pandapipes/pf/pipeflow_setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index d33ae967b..03f8ad9f1 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -190,7 +190,7 @@ def set_user_pf_options(net, reset=False, **kwargs): :type net: pandapipesNet :param reset: Specifies whether the user_pf_options is removed before setting new options :type reset: bool, default False - :param kwargs: pipeflow options that shall be set, e.g. tol_v = 1e-7 + :param kwargs: pipeflow options that shall be set, e.g. tol_m = 1e-7 :return: No output """ if reset or 'user_pf_options' not in net.keys(): @@ -217,7 +217,7 @@ def init_options(net, local_parameters): - **tol_p** (float): 1e-4 - The relative tolerance for the pressure. A result is accepted \ if the relative error is smaller than this factor. - - **tol_v** (float): 1e-4 - The relative tolerance for the velocity. A result is accepted \ + - **tol_m** (float): 1e-4 - The relative tolerance for the velocity. A result is accepted \ if the relative error is smaller than this factor. - **tol_T** (float): 1e-4 - The relative tolerance for the temperature. A result is \ From b5e3740994089b8645e0f153ec6ffecfc85e938a Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:18:58 +0100 Subject: [PATCH 086/237] import error --- src/pandapipes/pf/pipeflow_setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 03f8ad9f1..702cec44d 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -6,6 +6,7 @@ import inspect import numpy as np +from pandapower.auxiliary import ppException from scipy.sparse import coo_matrix, csgraph from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ From 3fb9cc07c4fd8273b47e563382716907f693d948 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:19:14 +0100 Subject: [PATCH 087/237] increase number of iterations --- src/pandapipes/test/api/test_components/test_ext_grid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index 082c560b6..bf1ea4f8f 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -214,7 +214,7 @@ def test_t_type_tee_2zu_2ab(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + pandapipes.pipeflow(net, stop_condition="tol", iter=5, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -243,7 +243,7 @@ def test_t_type_tee_2zu_2ab(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=3, friction_model="nikuradse", + pandapipes.pipeflow(net2, stop_condition="tol", iter=5, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) From faa7b49cfd274f281ce252517e6aad47b34185a7 Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:19:49 +0100 Subject: [PATCH 088/237] still required todo --- src/pandapipes/test/api/test_special_networks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pandapipes/test/api/test_special_networks.py b/src/pandapipes/test/api/test_special_networks.py index f577a846b..29a588dab 100644 --- a/src/pandapipes/test/api/test_special_networks.py +++ b/src/pandapipes/test/api/test_special_networks.py @@ -114,6 +114,7 @@ def test_random_net_and_one_node_net(create_test_net, use_numba): @pytest.mark.xfail(reason="The test net is not set up properly.") def test_wild_indexing(create_net_changed_indices): + # todo: still required? net = copy.deepcopy(create_net_changed_indices) pandapipes.pipeflow(net) From 3db61c13a84c061a5172db85ca43008222a1d9ff Mon Sep 17 00:00:00 2001 From: SRDM Date: Fri, 23 Feb 2024 13:20:01 +0100 Subject: [PATCH 089/237] tol_v to tol_m --- src/pandapipes/test/pipeflow_internals/test_inservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 32d06670d..31fc269d5 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -229,7 +229,7 @@ def test_connectivity_hydraulic(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_v=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_junction.p_bar.loc[[2, 5, 6]].values)) From 2a0acbe3c88d4cb0c6291ec21b876efb27cc6bb8 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Wed, 28 Feb 2024 11:16:16 +0100 Subject: [PATCH 090/237] renamed JAC_DERIV_DT1 to JAC_DERIV_DTOUT in branch_idx --- src/pandapipes/idx_branch.py | 2 +- src/pandapipes/pf/build_system_matrix.py | 4 ++-- src/pandapipes/pf/derivative_calculation.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py index 5104ea279..776bf953f 100644 --- a/src/pandapipes/idx_branch.py +++ b/src/pandapipes/idx_branch.py @@ -30,7 +30,7 @@ CP = 21 # Slot for fluid heat capacity values ALPHA = 22 # Slot for heat transfer coefficient JAC_DERIV_DT = 23 -JAC_DERIV_DT1 = 24 +JAC_DERIV_DTOUT = 24 LOAD_VEC_BRANCHES_T = 25 TOUTINIT = 26 # Internal slot for outlet pipe temperature JAC_DERIV_DT_NODE = 27 # Slot for the derivative fpr T for the nodes connected to branch diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index e388d2f84..9165225f2 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -4,7 +4,7 @@ import numpy as np from pandapipes.idx_branch import FROM_NODE, TO_NODE, JAC_DERIV_DV, JAC_DERIV_DP, JAC_DERIV_DP1, \ - JAC_DERIV_DV_NODE, LOAD_VEC_NODES, LOAD_VEC_BRANCHES, JAC_DERIV_DT, JAC_DERIV_DT1, \ + JAC_DERIV_DV_NODE, LOAD_VEC_NODES, LOAD_VEC_BRANCHES, JAC_DERIV_DT, JAC_DERIV_DTOUT, \ JAC_DERIV_DT_NODE, LOAD_VEC_NODES_T, LOAD_VEC_BRANCHES_T, FROM_NODE_T, TO_NODE_T, BRANCH_TYPE from pandapipes.idx_node import LOAD, TINIT from pandapipes.idx_node import P, PC, NODE_TYPE, T, NODE_TYPE_T @@ -82,7 +82,7 @@ def build_system_matrix(net, branch_pit, node_pit, heat_mode): else: system_data[:len_b] = branch_pit[:, JAC_DERIV_DT] # pdF_dpi1 - system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DT1] + system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DTOUT] # jdF_dv_from_nodes system_data[2 * len_b:len_fn1] = inc_flow_sum[tn_unique_der] # jdF_dv_to_nodes diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 7298adbd8..2fa258de6 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -3,7 +3,7 @@ from pandapipes.idx_branch import LENGTH, ETA, RHO, D, K, RE, LAMBDA, LOAD_VEC_BRANCHES, \ JAC_DERIV_DV, JAC_DERIV_DP, JAC_DERIV_DP1, LOAD_VEC_NODES, JAC_DERIV_DV_NODE, VINIT, \ FROM_NODE, TO_NODE, CP, VINIT_T, FROM_NODE_T, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ - LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE + LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DTOUT, JAC_DERIV_DT_NODE from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.properties.fluids import get_fluid @@ -94,7 +94,7 @@ def calculate_derivatives_thermal(net, branch_pit, node_pit, options): - alpha * (t_amb - t_m) * length + qext) branch_pit[:, JAC_DERIV_DT] = - rho * area * cp * v_init + alpha / 2 * length - branch_pit[:, JAC_DERIV_DT1] = rho * area * cp * v_init + alpha / 2 * length + branch_pit[:, JAC_DERIV_DTOUT] = rho * area * cp * v_init + alpha / 2 * length branch_pit[:, JAC_DERIV_DT_NODE] = rho * v_init * branch_pit[:, AREA] branch_pit[:, LOAD_VEC_NODES_T] = rho * v_init * branch_pit[:, AREA] \ From aa8501c8d250af30ef8128b9c0b18749a4e70677 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 11:35:24 +0100 Subject: [PATCH 091/237] small adaptions for cleaner coding --- src/pandapipes/properties/fluids.py | 3 ++- src/pandapipes/test/api/test_special_networks.py | 2 -- src/pandapipes/test/test_toolbox.py | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pandapipes/properties/fluids.py b/src/pandapipes/properties/fluids.py index c97a89604..2fb040a71 100644 --- a/src/pandapipes/properties/fluids.py +++ b/src/pandapipes/properties/fluids.py @@ -330,8 +330,9 @@ def get_at_value(self, *args): if self.warn_dependent_variables: logger.warning('Constant property received several input variables, although it is' 'independent of these') + # todo: if condition needs to be removed and args[0] if not hasattr(args[0], "__len__"): - output = np.array([self.value]) + output = self.value else: output = np.array([self.value]) * np.ones(len(args[0])) else: diff --git a/src/pandapipes/test/api/test_special_networks.py b/src/pandapipes/test/api/test_special_networks.py index 29a588dab..23ddd7727 100644 --- a/src/pandapipes/test/api/test_special_networks.py +++ b/src/pandapipes/test/api/test_special_networks.py @@ -114,9 +114,7 @@ def test_random_net_and_one_node_net(create_test_net, use_numba): @pytest.mark.xfail(reason="The test net is not set up properly.") def test_wild_indexing(create_net_changed_indices): - # todo: still required? net = copy.deepcopy(create_net_changed_indices) - pandapipes.pipeflow(net) assert net.converged diff --git a/src/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py index 973d30895..eedd94033 100644 --- a/src/pandapipes/test/test_toolbox.py +++ b/src/pandapipes/test/test_toolbox.py @@ -6,16 +6,15 @@ import os import numpy as np +import pandapipes import pandapower import pandas as pd import pytest from packaging import version - -import pandapipes from pandapipes import networks as nw, BranchComponent from pandapipes.component_models import NodeComponent -from pandapipes.idx_node import node_cols from pandapipes.idx_branch import branch_cols +from pandapipes.idx_node import node_cols from pandapipes.test.api.test_convert_format import found_versions, folder, minimal_version_two_nets @@ -132,7 +131,7 @@ def create_net_changed_indices(base_net_is_wo_pumps): net = copy.deepcopy(base_net_is_wo_pumps) new_junction_indices = [55, 38, 84, 65, 83, 82, 28, 49, 99, 105] - new_pipe_indices = [30, 88, 72, 99, 0, 98, 70] + new_pipe_indices = [30, 88, 72, 99, 0, 98, 70] new_valve_indices = [19] new_pump_indices = [93] new_hxc_indices = [67] From 3a9986da7013ed2b576f7dacacb6637e23e00b47 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 11:35:57 +0100 Subject: [PATCH 092/237] handle also small masses --- src/pandapipes/pf/derivative_calculation.py | 36 ++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 1442a9aa0..0e13d40bc 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -197,28 +197,34 @@ def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area): """ # TODO: check if some formulas with constants can be shortened - m_corr = np.where(np.abs(m) < 0.00001, 0.00001, m) + b_term = np.zeros_like(m) + df_dm = np.zeros_like(m) + df_dlambda = np.zeros_like(m) + lambda_der = np.zeros_like(m) + pos = m != 0 if friction_model == "colebrook": - b_term = 2.51 * eta * area / (m_corr * d * np.sqrt(lambda_pipe)) + k / (3.71 * d) + b_term[pos] = (2.51 * eta[pos] * area[pos] / (m[pos] * d[pos] * np.sqrt(lambda_pipe[pos])) + + k[pos] / (3.71 * d[pos])) - df_dm = -2 * 2.51 * eta * area / (m_corr ** 2 * np.sqrt(lambda_pipe) * d) \ - / (np.log(10) * b_term) + df_dm[pos] = -2 * 2.51 * eta[pos] * area[pos] / (m[pos] ** 2 * np.sqrt(lambda_pipe[pos]) * d[pos]) \ + / (np.log(10) * b_term[pos]) - df_dlambda = -0.5 * lambda_pipe ** (-3 / 2) - (2.51 * eta * area / (d * m_corr)) \ - * lambda_pipe ** (-3 / 2) / (np.log(10) * b_term) + df_dlambda[pos] = -0.5 * lambda_pipe[pos] ** (-3 / 2) - (2.51 * eta[pos] * area[pos] / (d[pos] * m[pos])) \ + * lambda_pipe[pos] ** (-3 / 2) / (np.log(10) * b_term[pos]) - lambda_colebrook_der = df_dm / df_dlambda + lambda_der[pos] = df_dm[pos] / df_dlambda[pos] - return lambda_colebrook_der + return lambda_der elif friction_model == "swamee-jain": - param = k / (3.7 * d) + 5.74 * (np.abs(eta * area)) ** 0.9 / ((np.abs(m_corr * d)) ** 0.9) + param = (k[pos] / (3.7 * d[pos]) + 5.74 * (np.abs(eta[pos] * area[pos])) ** 0.9 / + ((np.abs(m[pos] * d[pos])) ** 0.9)) # 0.5 / (log(10) * log(param)^3 * param) * 5.166 * abs(eta)^0.9 / (abs(rho * d)^0.9 # * abs(v_corr)^1.9) - lambda_swamee_jain_der = 0.5 * np.log(10) ** 2 / (np.log(param) ** 3) / param * 5.166 \ - * np.abs(eta * area) ** 0.9 / ((np.abs(d) ** 0.9) - * np.abs(m_corr) ** 1.9) - return lambda_swamee_jain_der + lambda_der[pos] = 0.5 * np.log(10) ** 2 / (np.log(param) ** 3) / param * 5.166 \ + * np.abs(eta[pos] * area[pos]) ** 0.9 / ((np.abs(d[pos]) ** 0.9) + * np.abs(m[pos]) ** 1.9) + return lambda_der else: - lambda_laminar_der = -(64 * eta * area) / (m_corr ** 2 * d) - return lambda_laminar_der + lambda_der[pos] = -(64 * eta[pos] * area[pos]) / (m[pos] ** 2 * d[pos]) + return lambda_der From a9f038deb0f2a7cec357e597afee64363818d60b Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 11:48:43 +0100 Subject: [PATCH 093/237] make sure to find tutorials folder --- .github/workflows/run_tests_develop.yml | 2 +- src/pandapipes/test/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index acf46022d..4f379dc91 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -110,7 +110,7 @@ jobs: python -m pip list - name: Test with pytest run: | - python -m pytest --nbmake -n=auto "./tutorials" + python -m pytest --nbmake -n=auto "../tutorials" docs_check: runs-on: ubuntu-latest diff --git a/src/pandapipes/test/__init__.py b/src/pandapipes/test/__init__.py index 3b8e845a2..ed03a51ee 100644 --- a/src/pandapipes/test/__init__.py +++ b/src/pandapipes/test/__init__.py @@ -7,7 +7,7 @@ test_path = os.path.join(pp_dir, 'test') data_path = os.path.join(test_path, "data") -tutorials_path = os.path.join(os.path.dirname(pp_dir), 'tutorials') +tutorials_path = os.path.join(os.path.dirname(pp_dir), '..', 'tutorials') from pandapipes.test.run_tests import * from pandapipes.test.test_imports import * from pandapipes.test.test_toolbox import * From 58fd7b5b6acb81ea5aaaff443df163a2ba855be6 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 12:02:25 +0100 Subject: [PATCH 094/237] nbmake bug due to pytest 8.1.0 upgrade --- .github/workflows/run_tests_develop.yml | 4 ++-- .github/workflows/run_tests_master.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 4f379dc91..6a8fc845a 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -99,7 +99,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split igraph + python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split igraph if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower @@ -110,7 +110,7 @@ jobs: python -m pip list - name: Test with pytest run: | - python -m pytest --nbmake -n=auto "../tutorials" + python -m pytest --nbmake -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 9be8fe64f..0adfcb402 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -66,7 +66,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split igraph + python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split igraph if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower From fa8e21b2f971b369866fc9f7ec9f4ca3588f4b28 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 12:10:54 +0100 Subject: [PATCH 095/237] bugfix --- src/pandapipes/properties/properties_toolbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index e7bcb7857..d3f55ba9e 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -156,7 +156,7 @@ def get_branch_density(net, fluid, node_pit, branch_pit): if fluid.is_gas: from_p = node_pit[from_nodes, PINIT] + node_pit[from_nodes, PAMB] to_nodes = branch_pit[:, TO_NODE].astype(int) - to_p = node_pit[to_nodes, PINIT] + node_pit[from_nodes, PAMB] + to_p = node_pit[to_nodes, PINIT] + node_pit[to_nodes, PAMB] normal_rho = fluid.get_density(NORMAL_TEMPERATURE) from_rho = np.divide(normal_rho * NORMAL_TEMPERATURE * from_p, t_from * NORMAL_PRESSURE * fluid.get_compressibility(from_p)) From 4cb50a734f537e9466be76f543d8f3aa4a5c888d Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 12:11:48 +0100 Subject: [PATCH 096/237] remove unnecessary fluid call --- src/pandapipes/properties/properties_toolbox.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index d3f55ba9e..d511002d9 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -163,7 +163,6 @@ def get_branch_density(net, fluid, node_pit, branch_pit): to_rho = np.divide(normal_rho * NORMAL_TEMPERATURE * to_p, t_to * NORMAL_PRESSURE * fluid.get_compressibility(to_p)) else: - fluid = get_fluid(net) from_rho = fluid.get_density(t_from) to_rho = fluid.get_density(t_to) rho = (from_rho + to_rho) / 2 From f26a51a03b4a81c752862e9b04ba85de0730ddf7 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:05:33 +0100 Subject: [PATCH 097/237] scientific writing, improve readibility --- .../component_models/pump_component.py | 4 +- .../test/stanet_comparison/test_gas_stanet.py | 84 +++++++++--------- .../stanet_comparison/test_water_stanet.py | 88 +++++++++---------- 3 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index 4021ff2b2..a874844a1 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -179,11 +179,11 @@ def extract_results(cls, net, options, branch_results, mode): w_real_isentr = (k / (k - 1)) * r_spec * compr * t0 * \ (np.divide(p_to, p_from) ** ((k - 1) / k) - 1) res_table['compr_power_mw'].values[:] = \ - w_real_isentr * np.abs(mf_sum_int) / 10 ** 6 + w_real_isentr * np.abs(mf_sum_int) / 1e6 else: vf_sum_int = branch_results["vf"][f:t] pl = branch_results["pl"][f:t] - res_table['compr_power_mw'].values[:] = pl * P_CONVERSION * vf_sum_int / 10 ** 6 + res_table['compr_power_mw'].values[:] = pl * P_CONVERSION * vf_sum_int / 1e6 @classmethod def get_component_input(cls): diff --git a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py index b283552b6..622cbef2b 100644 --- a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py @@ -32,8 +32,8 @@ def test_case_3parallel_n(use_numba, log_results=False): """ net = nw.gas_3parallel(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # parallel_PC @@ -49,8 +49,8 @@ def test_case_combined_3parallel_pc(use_numba, log_results=False): net = nw.gas_3parallel(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # ---------- TEST AREA: meshed networks ---------- @@ -66,8 +66,8 @@ def test_case_square_n(use_numba, log_results=False): """ net = nw.gas_meshed_square(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # square_PC @@ -83,8 +83,8 @@ def test_case_square_pc(use_numba, log_results=False): net = nw.gas_meshed_square(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # delta_PC @@ -100,8 +100,8 @@ def test_case_meshed_delta_pc(use_numba, log_results=False): net = nw.gas_meshed_delta() p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pumps_N @@ -117,8 +117,8 @@ def test_case_meshed_pumps(use_numba, log_results=False): net = nw.gas_meshed_pumps() p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, calc_compression_power=False) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # two_valves_N @@ -126,8 +126,8 @@ def test_case_meshed_pumps(use_numba, log_results=False): def test_case_meshed_2valves_n(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -3) - assert np.all(v_diff_abs < 10 ** -3) + assert np.all(p_diff < 1e-3) + assert np.all(v_diff_abs < 1e-3) # two_valves_PC @@ -136,8 +136,8 @@ def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -3) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-3) # ---------- TEST AREA: one pipe ---------- @@ -153,8 +153,8 @@ def test_case_one_pipe1_n(use_numba, log_results=False): """ net = nw.gas_one_pipe1(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # pipe_1_PC @@ -170,8 +170,8 @@ def test_case_one_pipe1_pc(use_numba, log_results=False): net = nw.gas_one_pipe1(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # pipe_2_N @@ -186,8 +186,8 @@ def test_case_one_pipe2_n(use_numba, log_results=False): """ net = nw.gas_one_pipe2(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_2_PC @@ -203,8 +203,8 @@ def test_case_one_pipe2_pc(use_numba, log_results=False): net = nw.gas_one_pipe2(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # ---------- TEST AREA: strand net ---------- @@ -220,8 +220,8 @@ def test_case_strand_2pipes_n(use_numba, log_results=False): """ net = nw.gas_strand_2pipes(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # two_pipes_PC @@ -237,8 +237,8 @@ def test_case_strand_2pipes_pc(use_numba, log_results=False): net = nw.gas_strand_2pipes(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # pump_N @pytest.mark.parametrize("use_numba", [True, False]) @@ -253,8 +253,8 @@ def test_case_strand_pump(use_numba, log_results=False): net = nw.gas_strand_pump() p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, calc_compression_power=False) - assert np.all(p_diff < 0.01) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 1e-2) + assert np.all(v_diff_abs < 3e-2) # ---------- TEST AREA: t_cross ---------- @@ -270,8 +270,8 @@ def test_case_tcross1_n(use_numba, log_results=False): """ net = nw.gas_tcross1(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # t-cross1_PC @@ -287,8 +287,8 @@ def test_case_tcross1_pc(use_numba, log_results=False): net = nw.gas_tcross1(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # t-cross2_N @@ -303,8 +303,8 @@ def test_case_tcross2_n(use_numba, log_results=False): """ net = nw.gas_tcross2(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # t-cross2_PC @@ -320,8 +320,8 @@ def test_case_tcross2_pc(use_numba, log_results=False): net = nw.gas_tcross2(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # ---------- TEST AREA: two pressure junctions ---------- @@ -337,8 +337,8 @@ def test_case_2eg_hnet_n(use_numba, log_results=False): """ net = nw.gas_2eg_hnet(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # H-net_PC @@ -354,8 +354,8 @@ def test_case_2eg_hnet_pc(use_numba, log_results=False): net = nw.gas_2eg_hnet(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", use_numba=use_numba) - assert np.all(p_diff < 10 ** -4) - assert np.all(v_diff_abs < 10 ** -2) + assert np.all(p_diff < 1e-4) + assert np.all(v_diff_abs < 1e-2) # # ---------------------------------------- # def test_case12(log_results=False): diff --git a/src/pandapipes/test/stanet_comparison/test_water_stanet.py b/src/pandapipes/test/stanet_comparison/test_water_stanet.py index 0c7976e25..cb64b20a9 100644 --- a/src/pandapipes/test/stanet_comparison/test_water_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_water_stanet.py @@ -31,8 +31,8 @@ def test_case_district_grid_n(use_numba, log_results=False): """ net = nw.water_district_grid(method="n") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # district_PC @@ -48,8 +48,8 @@ def test_case_district_grid_pc(use_numba, log_results=False): net = nw.water_district_grid(method="pc") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.03) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 3e-2) + assert np.all(v_diff_abs < 3e-2) # ---------- TEST AREA: meshed networks ---------- @@ -65,8 +65,8 @@ def test_case_pumps_n(use_numba, log_results=False): """ net = nw.water_meshed_pumps(results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # delta_N @@ -81,8 +81,8 @@ def test_case_delta_n(use_numba, log_results=False): """ net = nw.water_meshed_delta(results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # two_valves_N @@ -90,8 +90,8 @@ def test_case_delta_n(use_numba, log_results=False): def test_case_meshed_2valves_n(use_numba, log_results=False): net = nw.water_meshed_2valves(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.001) - assert np.all(v_diff_abs < 0.001) + assert np.all(p_diff < 1e-3) + assert np.all(v_diff_abs < 1e-3) # two_valves_PC @@ -100,8 +100,8 @@ def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.water_meshed_2valves(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.001) - assert np.all(v_diff_abs < 0.001) + assert np.all(p_diff < 1e-3) + assert np.all(v_diff_abs < 1e-3) # ---------- TEST AREA: one pipe ---------- @@ -117,8 +117,8 @@ def test_case_one_pipe1_n(use_numba, log_results=False): """ net = nw.water_one_pipe1(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_1_PC @@ -134,8 +134,8 @@ def test_case_one_pipe1_pc(use_numba, log_results=False): net = nw.water_one_pipe1(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_2_N @@ -150,8 +150,8 @@ def test_case_one_pipe2_n(use_numba, log_results=False): """ net = nw.water_one_pipe2(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_2_PC @@ -167,8 +167,8 @@ def test_case_one_pipe2_pc(use_numba, log_results=False): net = nw.water_one_pipe2(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_3_N @@ -183,8 +183,8 @@ def test_case_one_pipe3_n(use_numba, log_results=False): """ net = nw.water_one_pipe3(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pipe_3_PC @@ -200,8 +200,8 @@ def test_case_one_pipe3_pc(use_numba, log_results=False): net = nw.water_one_pipe3(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # ---------- TEST AREA: strand net ---------- @@ -217,8 +217,8 @@ def test_case_simple_strand_net_n(use_numba, log_results=False): """ net = nw.water_simple_strand_net(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # strand_net_PC @@ -234,8 +234,8 @@ def test_case_simple_strand_net_pc(use_numba, log_results=False): net = nw.water_simple_strand_net(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.01) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 1e-2) + assert np.all(v_diff_abs < 3e-2) # two_pipes_N @@ -250,8 +250,8 @@ def test_case_two_pipes_n(use_numba, log_results=False): """ net = nw.water_strand_2pipes(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # two_pipes_PC @@ -267,8 +267,8 @@ def test_case_two_pipes_pc(use_numba, log_results=False): net = nw.water_strand_2pipes(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # cross_PC @@ -284,8 +284,8 @@ def test_case_cross_pc(use_numba, log_results=False): net = nw.water_strand_cross(results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # pump_N @@ -300,8 +300,8 @@ def test_case_pump_n(use_numba, log_results=False): """ net = nw.water_strand_pump() p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # ---------- TEST AREA: t_cross ---------- @@ -317,8 +317,8 @@ def test_case_tcross_n(use_numba, log_results=False): """ net = nw.water_tcross(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # t-cross_PC @@ -334,8 +334,8 @@ def test_case_tcross_pc(use_numba, log_results=False): net = nw.water_tcross(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # ---------- TEST AREA: two pressure junctions ---------- @@ -351,8 +351,8 @@ def test_case_2eg_two_pipes_n(use_numba, log_results=False): """ net = nw.water_2eg_two_pipes(method="n", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) # two_pipes_PC @@ -368,8 +368,8 @@ def test_case_2eg_two_pipes_pc(use_numba, log_results=False): net = nw.water_2eg_two_pipes(method="pc", results_from="stanet") p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, friction_model="colebrook") - assert np.all(p_diff < 0.002) - assert np.all(v_diff_abs < 0.03) + assert np.all(p_diff < 2e-3) + assert np.all(v_diff_abs < 3e-2) if __name__ == "__main__": From 7a16a7ac9eb25ebcfd4e7386e123cd77d4b26b25 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:13:50 +0100 Subject: [PATCH 098/237] use correct density for volume flow --- src/pandapipes/pf/result_extraction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 7ff21a7b6..a28d2d4d0 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -7,6 +7,7 @@ from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option from pandapipes.properties.fluids import get_fluid +from pandapipes.properties.properties_toolbox import get_branch_density try: from numba import jit @@ -60,7 +61,7 @@ def get_basic_branch_results(net, branch_pit, node_pit): fluid = get_fluid(net) t0 = node_pit[from_nodes, TINIT_NODE] t1 = node_pit[to_nodes, TINIT_NODE] - vf = branch_pit[:, MINIT] / fluid.get_density((t0 + t1) / 2) + vf = branch_pit[:, MINIT] / get_branch_density(net,fluid, node_pit, branch_pit) v = branch_pit[:, MINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] return v, branch_pit[:, MINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ From 940bc791422b5f8f94075a4bfecd1f4aa674f42b Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:18:26 +0100 Subject: [PATCH 099/237] removed unused import --- .../abstract_models/branch_wo_internals_models.py | 1 - src/pandapipes/properties/properties_toolbox.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py index e57dbb7f5..9af9e0df3 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py @@ -8,7 +8,6 @@ from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup -from pandapipes.properties.fluids import get_fluid try: import pandaplan.core.pplog as logging diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index d511002d9..c7e7c9e73 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -7,7 +7,6 @@ from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE from pandapipes.idx_branch import TOUTINIT, FROM_NODE, TO_NODE from pandapipes.idx_node import TINIT, PINIT, PAMB -from pandapipes.properties.fluids import get_fluid def calculate_mixture_viscosity(components_viscosities, components_molar_proportions, From e3ca2e3187ae4a36cf7f3820e01f9b3816eb4ca2 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:18:37 +0100 Subject: [PATCH 100/237] use enumerate --- src/pandapipes/pf/derivative_toolbox_numba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index e0058117b..6c6603968 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -109,8 +109,8 @@ def calc_lambda_nikuradse_comp_numba(m, d, k, eta, area): lambda_nikuradse = np.empty_like(m) lambda_laminar = np.zeros_like(m) re = np.empty_like(m) - for i in range(len(m)): - m_abs = np.abs(m[i]) + for i, mi in enumerate(m): + m_abs = np.abs(mi) re[i] = np.divide(m_abs * d[i], eta[i] * area[i]) if re[i] != 0: lambda_laminar[i] = np.divide(64, re[i]) From 357f5aafe795158d43659fc7ca8c442d2b844ff4 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:24:07 +0100 Subject: [PATCH 101/237] renamed MINIT into MDOTINIT --- .../abstract_models/branch_models.py | 4 ++-- .../component_models/compressor_component.py | 4 ++-- .../component_models/flow_control_component.py | 7 ++++--- .../component_models/pipe_component.py | 6 +++--- .../component_models/pump_component.py | 4 ++-- src/pandapipes/idx_branch.py | 4 ++-- src/pandapipes/pf/derivative_calculation.py | 8 ++++---- src/pandapipes/pf/derivative_toolbox.py | 14 +++++++------- src/pandapipes/pf/derivative_toolbox_numba.py | 14 +++++++------- src/pandapipes/pf/pipeflow_setup.py | 6 +++--- src/pandapipes/pf/result_extraction.py | 12 ++++++------ src/pandapipes/pipeflow.py | 18 +++++++++--------- .../pipeflow_internals/test_pipeflow_modes.py | 6 +++--- 13 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index 184b98a18..8ebf80323 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -5,7 +5,7 @@ import numpy as np from pandapipes.component_models.abstract_models.base_component import Component -from pandapipes.idx_branch import MINIT, branch_cols +from pandapipes.idx_branch import MDOTINIT, branch_cols from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup try: @@ -88,7 +88,7 @@ def create_pit_branch_entries(cls, net, branch_pit): from_nodes = junction_idx_lookup[net[cls.table_name()][fn_col].values] to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) - branch_component_pit[:, MINIT] = 0.1 + branch_component_pit[:, MDOTINIT] = 0.1 return branch_component_pit, node_pit, from_nodes, to_nodes @classmethod diff --git a/src/pandapipes/component_models/compressor_component.py b/src/pandapipes/component_models/compressor_component.py index 21beca1c3..3d16b7b5d 100644 --- a/src/pandapipes/component_models/compressor_component.py +++ b/src/pandapipes/component_models/compressor_component.py @@ -8,7 +8,7 @@ from pandapipes.component_models.component_toolbox import get_component_array from pandapipes.component_models.junction_component import Junction from pandapipes.component_models.pump_component import Pump -from pandapipes.idx_branch import MINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL +from pandapipes.idx_branch import MDOTINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL from pandapipes.idx_node import PINIT, PAMB @@ -76,7 +76,7 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo p_to_calc = p_from * compressor_array[:, cls.PRESSURE_RATIO] pl_abs = p_to_calc - p_from - m_mps = compressor_branch_pit[:, MINIT] + m_mps = compressor_branch_pit[:, MDOTINIT] pl_abs[m_mps < 0] = 0 # force pressure lift = 0 for reverse flow compressor_branch_pit[:, PL] = pl_abs diff --git a/src/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py index 66f884b88..fbcf909d1 100644 --- a/src/pandapipes/component_models/flow_control_component.py +++ b/src/pandapipes/component_models/flow_control_component.py @@ -5,11 +5,12 @@ import numpy as np from numpy import dtype -from pandapipes.component_models.abstract_models import BranchWZeroLengthComponent, get_fluid +from pandapipes.component_models.abstract_models import BranchWZeroLengthComponent +from pandapipes.properties import get_fluid from pandapipes.component_models.component_toolbox import \ standard_branch_wo_internals_result_lookup, get_component_array from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MINIT, LOAD_VEC_BRANCHES +from pandapipes.idx_branch import D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -50,7 +51,7 @@ def create_pit_branch_entries(cls, net, branch_pit): fc_branch_pit = super().create_pit_branch_entries(net, branch_pit) fc_branch_pit[:, D] = net[cls.table_name()].diameter_m.values fc_branch_pit[:, AREA] = fc_branch_pit[:, D] ** 2 * np.pi / 4 - fc_branch_pit[:, MINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values + fc_branch_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values @classmethod def create_component_array(cls, net, component_pits): diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index c51373879..a461b7b6a 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -11,7 +11,7 @@ from pandapipes.component_models.junction_component import Junction from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \ - MINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC + MDOTINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, PAMB, ACTIVE as ACTIVE_ND from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \ @@ -150,7 +150,7 @@ def create_pit_branch_entries(cls, net, branch_pit): pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals) pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4 - pipe_pit[:, MINIT] *= pipe_pit[:, AREA] * get_fluid(net).get_density(NORMAL_TEMPERATURE) + pipe_pit[:, MDOTINIT] *= pipe_pit[:, AREA] * get_fluid(net).get_density(NORMAL_TEMPERATURE) @classmethod def extract_results(cls, net, options, branch_results, mode): @@ -227,7 +227,7 @@ def get_internal_results(cls, net, pipe): p_nodes = int_p_lookup[:, 1][selected_indices_p_final] m_nodes = int_v_lookup[:, 1][selected_indices_v_final] - v_pipe_data = pipe_pit[m_nodes, MINIT] / fluid.get_density(NORMAL_TEMPERATURE) / pipe_pit[m_nodes, AREA] + v_pipe_data = pipe_pit[m_nodes, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / pipe_pit[m_nodes, AREA] p_node_data = node_pit[p_nodes, PINIT] t_node_data = node_pit[p_nodes, TINIT_NODE] diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index a874844a1..eeaa8938e 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -12,7 +12,7 @@ from pandapipes.component_models.component_toolbox import get_component_array from pandapipes.component_models.junction_component import Junction from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE, R_UNIVERSAL, P_CONVERSION -from pandapipes.idx_branch import MINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL +from pandapipes.idx_branch import MDOTINIT, D, AREA, LOSS_COEFFICIENT as LC, FROM_NODE, PL from pandapipes.idx_node import PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import get_fluid, get_net_option, get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -104,7 +104,7 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo # p_to = node_pit[to_nodes, PAMB] + node_pit[to_nodes, PINIT] t_from = node_pit[from_nodes, TINIT_NODE] numerator_from = NORMAL_PRESSURE * t_from - v_mps = pump_branch_pit[:, MINIT] / pump_branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) + v_mps = pump_branch_pit[:, MDOTINIT] / pump_branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) if fluid.is_gas: # consider volume flow at inlet normfactor_from = numerator_from * fluid.get_property("compressibility", p_from) \ diff --git a/src/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py index 7da13eccd..776f74c2c 100644 --- a/src/pandapipes/idx_branch.py +++ b/src/pandapipes/idx_branch.py @@ -15,7 +15,7 @@ D = 6 # Diameter in [m] AREA = 7 # Area in [m²] K = 8 # Pipe roughness in [m] -MINIT = 9 # mass in [m/s] +MDOTINIT = 9 # mass in [m/s] RE = 10 # Reynolds number LAMBDA = 11 # Lambda JAC_DERIV_DM = 12 # Slot for the derivative by mass @@ -32,7 +32,7 @@ TOUTINIT = 23 # Internal slot for outlet pipe temperature JAC_DERIV_DT_NODE = 24 # Slot for the derivative fpr T for the nodes connected to branch LOAD_VEC_NODES_T = 25 -MINIT_T = 26 +MDOTINIT_T = 26 FROM_NODE_T = 27 TO_NODE_T = 28 QEXT = 29 # heat input in [W] diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 0e13d40bc..227dd6074 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -3,7 +3,7 @@ from pandapipes.idx_branch import LENGTH, D, K, RE, LAMBDA, LOAD_VEC_BRANCHES, \ JAC_DERIV_DM, JAC_DERIV_DP, JAC_DERIV_DP1, LOAD_VEC_NODES, JAC_DERIV_DM_NODE, \ FROM_NODE, TO_NODE, FROM_NODE_T, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ - LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE, MINIT, MINIT_T + LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE, MDOTINIT, MDOTINIT_T from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.properties.fluids import get_fluid from pandapipes.constants import NORMAL_TEMPERATURE @@ -32,9 +32,9 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): rho_n = fluid.get_density([NORMAL_TEMPERATURE] * len(branch_pit)) lambda_, re = calc_lambda( - branch_pit[:, MINIT], eta, branch_pit[:, D], + branch_pit[:, MDOTINIT], eta, branch_pit[:, D], branch_pit[:, K], gas_mode, friction_model, branch_pit[:, LENGTH], options, branch_pit[:, AREA]) - der_lambda = calc_der_lambda(branch_pit[:, MINIT], eta, + der_lambda = calc_der_lambda(branch_pit[:, MDOTINIT], eta, branch_pit[:, D], branch_pit[:, K], friction_model, lambda_, branch_pit[:, AREA]) branch_pit[:, RE] = re branch_pit[:, LAMBDA] = lambda_ @@ -82,7 +82,7 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): def calculate_derivatives_thermal(net, branch_pit, node_pit, options): fluid = get_fluid(net) cp = get_branch_cp(net, fluid, node_pit, branch_pit) - m_init = branch_pit[:, MINIT_T] + m_init = branch_pit[:, MDOTINIT_T] from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) t_init_i = node_pit[from_nodes, TINIT_NODE] t_init_i1 = branch_pit[:, TOUTINIT] diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index defe6427c..fa60302a5 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -8,14 +8,14 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ - MINIT, TOUTINIT, FROM_NODE + MDOTINIT, TOUTINIT, FROM_NODE from pandapipes.idx_node import HEIGHT, PINIT, PAMB, TINIT as TINIT_NODE def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, rho, rho_n): - m_init_abs = np.abs(branch_pit[:, MINIT]) - m_init2 = m_init_abs * branch_pit[:, MINIT] + m_init_abs = np.abs(branch_pit[:, MDOTINIT]) + m_init2 = m_init_abs * branch_pit[:, MDOTINIT] p_diff = p_init_i_abs - p_init_i1_abs const_height = rho * GRAVITATION_CONSTANT * height_difference / P_CONVERSION friction_term = np.divide(branch_pit[:, LENGTH] * branch_pit[:, LAMBDA], branch_pit[:, D]) + branch_pit[:, LC] @@ -31,7 +31,7 @@ def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init df_dm_nodes = np.ones_like(der_lambda) - load_vec_nodes = branch_pit[:, MINIT] + load_vec_nodes = branch_pit[:, MDOTINIT] return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 @@ -39,8 +39,8 @@ def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init def derivatives_hydraulic_comp_np(node_pit, branch_pit, lambda_, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, comp_fact, der_comp, der_comp1, rho, rho_n): # Formulas for gas pressure loss according to laminar version - m_init_abs = np.abs(branch_pit[:, MINIT]) - m_init2 = branch_pit[:, MINIT] * m_init_abs + m_init_abs = np.abs(branch_pit[:, MDOTINIT]) + m_init2 = branch_pit[:, MDOTINIT] * m_init_abs p_diff = p_init_i_abs - p_init_i1_abs p_sum = p_init_i_abs + p_init_i1_abs p_sum_div = np.divide(1, p_sum) @@ -62,7 +62,7 @@ def derivatives_hydraulic_comp_np(node_pit, branch_pit, lambda_, der_lambda, p_i - normal_term * comp_fact * m_init2 * friction_term * p_sum_div * tm df_dm_nodes = np.ones_like(lambda_) - load_vec_nodes = branch_pit[:, MINIT] + load_vec_nodes = branch_pit[:, MDOTINIT] return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 6c6603968..98de35aad 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -4,7 +4,7 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ - MINIT, FROM_NODE, TO_NODE + MDOTINIT, FROM_NODE, TO_NODE from pandapipes.idx_node import HEIGHT, PAMB, PINIT, TINIT as TINIT_NODE try: @@ -27,8 +27,8 @@ def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_i df_dm_nodes = np.ones_like(der_lambda) for i in range(le): - m_init_abs = np.abs(branch_pit[i][MINIT]) - m_init2 = m_init_abs * branch_pit[i][MINIT] + m_init_abs = np.abs(branch_pit[i][MDOTINIT]) + m_init2 = m_init_abs * branch_pit[i][MDOTINIT] p_diff = p_init_i_abs[i] - p_init_i1_abs[i] const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION friction_term = np.divide(branch_pit[i][LENGTH] * branch_pit[i][LAMBDA], branch_pit[i][D]) \ @@ -40,7 +40,7 @@ def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_i load_vec[i] = p_diff + branch_pit[i][PL] + const_height - const_term * m_init2 * friction_term - load_vec_nodes[i] = branch_pit[i][MINIT] + load_vec_nodes[i] = branch_pit[i][MDOTINIT] return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 @@ -61,8 +61,8 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, # Formulas for gas pressure loss according to laminar version for i in range(le): # compressibility settings - m_init_abs = np.abs(branch_pit[i][MINIT]) - m_init2 = branch_pit[i][MINIT] * m_init_abs + m_init_abs = np.abs(branch_pit[i][MDOTINIT]) + m_init2 = branch_pit[i][MDOTINIT] * m_init_abs p_diff = p_init_i_abs[i] - p_init_i1_abs[i] p_sum = p_init_i_abs[i] + p_init_i1_abs[i] p_sum_div = np.divide(1, p_sum) @@ -86,7 +86,7 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, df_dm[i] = normal_term * comp_fact[i] * p_sum_div * tm * (2 * m_init_abs * friction_term \ + np.divide(der_lambda[i] * branch_pit[i][LENGTH] * m_init2, branch_pit[i][D])) - load_vec_nodes[i] = branch_pit[i][MINIT] + load_vec_nodes[i] = branch_pit[i][MDOTINIT] return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 702cec44d..4e14205d2 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -10,7 +10,7 @@ from scipy.sparse import coo_matrix, csgraph from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ - ACTIVE as ACTIVE_BR, MINIT + ACTIVE as ACTIVE_BR, MDOTINIT from pandapipes.idx_node import NODE_TYPE, P, NODE_TYPE_T, node_cols, T, ACTIVE as ACTIVE_ND, \ TABLE_IDX as TABLE_IDX_ND, ELEMENT_IDX as ELEMENT_IDX_ND from pandapipes.pf.internals_toolbox import _sum_by_group @@ -517,8 +517,8 @@ def branches_connected_flow(branch_pit): :rtype: np.array """ # TODO: is this formulation correct or could there be any caveats? - return ~np.isnan(branch_pit[:, MINIT]) \ - & ~np.isclose(branch_pit[:, MINIT], 0, rtol=1e-10, atol=1e-10) + return ~np.isnan(branch_pit[:, MDOTINIT]) \ + & ~np.isclose(branch_pit[:, MDOTINIT], 0, rtol=1e-10, atol=1e-10) def check_connectivity(net, branch_pit, node_pit, mode="hydraulics"): diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index a28d2d4d0..93f9cf318 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -1,7 +1,7 @@ import numpy as np from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE -from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MINIT, RE, \ +from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MDOTINIT, RE, \ LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA from pandapipes.idx_node import TABLE_IDX as TABLE_IDX_NODE, PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.internals_toolbox import _sum_by_group @@ -61,9 +61,9 @@ def get_basic_branch_results(net, branch_pit, node_pit): fluid = get_fluid(net) t0 = node_pit[from_nodes, TINIT_NODE] t1 = node_pit[to_nodes, TINIT_NODE] - vf = branch_pit[:, MINIT] / get_branch_density(net,fluid, node_pit, branch_pit) - v = branch_pit[:, MINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] - return v, branch_pit[:, MINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ + vf = branch_pit[:, MDOTINIT] / get_branch_density(net,fluid, node_pit, branch_pit) + v = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] + return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ branch_pit[:, PL] @@ -284,8 +284,8 @@ def extract_results_active_pit(net, mode="hydraulics"): if i not in [not_affected_node_col]]) rows_nodes = np.arange(net["_pit"]["node"].shape[0])[nodes_connected] - result_branch_col = MINIT if mode == "hydraulics" else TOUTINIT - not_affected_branch_col = TOUTINIT if mode == "hydraulics" else MINIT + result_branch_col = MDOTINIT if mode == "hydraulics" else TOUTINIT + not_affected_branch_col = TOUTINIT if mode == "hydraulics" else MDOTINIT copied_branch_cols = np.array([i for i in range(net["_pit"]["branch"].shape[1]) if i not in [FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, not_affected_branch_col]]) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 2e2dda8de..c1b9699cf 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -6,7 +6,7 @@ from numpy import linalg from scipy.sparse.linalg import spsolve -from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MINIT, TOUTINIT, MINIT_T +from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, MDOTINIT_T from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal @@ -89,7 +89,7 @@ def pipeflow(net, sol_vec=None, **kwargs): "results are available.") else: net["_pit"]["node"][:, PINIT] = sol_vec[:len(node_pit)] - net["_pit"]["branch"][:, MINIT] = sol_vec[len(node_pit):] + net["_pit"]["branch"][:, MDOTINIT] = sol_vec[len(node_pit):] if calculate_hydraulics: reduce_pit(net, node_pit, branch_pit, mode="hydraulics") @@ -225,14 +225,14 @@ def solve_hydraulics(net): net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) - m_init_old = branch_pit[:, MINIT].copy() + m_init_old = branch_pit[:, MDOTINIT].copy() p_init_old = node_pit[:, PINIT].copy() x = spsolve(jacobian, epsilon) - branch_pit[:, MINIT] += x[len(node_pit):] + branch_pit[:, MDOTINIT] += x[len(node_pit):] node_pit[:, PINIT] += x[:len(node_pit)] * options["alpha"] - return branch_pit[:, MINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon + return branch_pit[:, MDOTINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon def solve_temperature(net): @@ -255,11 +255,11 @@ def solve_temperature(net): # Negative velocity values are turned to positive ones (including exchange of from_node and # to_node for temperature calculation - branch_pit[:, MINIT_T] = branch_pit[:, MINIT] + branch_pit[:, MDOTINIT_T] = branch_pit[:, MDOTINIT] branch_pit[:, FROM_NODE_T] = branch_pit[:, FROM_NODE] branch_pit[:, TO_NODE_T] = branch_pit[:, TO_NODE] - mask = branch_pit[:, MINIT] < 0 - branch_pit[mask, MINIT_T] = -branch_pit[mask, MINIT] + mask = branch_pit[:, MDOTINIT] < 0 + branch_pit[mask, MDOTINIT_T] = -branch_pit[mask, MDOTINIT] branch_pit[mask, FROM_NODE_T] = branch_pit[mask, TO_NODE] branch_pit[mask, TO_NODE_T] = branch_pit[mask, FROM_NODE] @@ -313,7 +313,7 @@ def set_damping_factor(net, niter, error): def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_method, tol_1, tol_2, tol_res, vals_1_old, vals_2_old, hydraulic_mode=True): - col1, col2 = (PINIT, MINIT) if hydraulic_mode else (TINIT, TOUTINIT) + col1, col2 = (PINIT, MDOTINIT) if hydraulic_mode else (TINIT, TOUTINIT) # Control of damping factor if nonlinear_method == "automatic": diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index a6a7487f0..2e361c75d 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -11,7 +11,7 @@ import pandapipes from pandapipes.constants import NORMAL_TEMPERATURE -from pandapipes.idx_branch import MINIT, AREA +from pandapipes.idx_branch import MDOTINIT, AREA from pandapipes.idx_node import PINIT from pandapipes.properties import get_fluid @@ -57,7 +57,7 @@ def test_hydraulic_only(simple_test_net, use_numba): p_pandapipes = node_pit[:, PINIT] fluid = get_fluid(net) - v_pandapipes = branch_pit[:, MINIT] / branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) + v_pandapipes = branch_pit[:, MDOTINIT] / branch_pit[:, AREA] / fluid.get_density(NORMAL_TEMPERATURE) p_diff = np.abs(1 - p_pandapipes / p_an) v_diff = np.abs(v_pandapipes - v_an) @@ -96,7 +96,7 @@ def test_heat_only(use_numba): pandapipes.pipeflow(ntw, stop_condition="tol", iter=50, friction_model="nikuradse", nonlinear_method="automatic", mode="hydraulics", use_numba=use_numba) p = ntw._pit["node"][:, PINIT] - m = ntw._pit["branch"][:, MINIT] + m = ntw._pit["branch"][:, MDOTINIT] u = np.concatenate((p, m)) pandapipes.pipeflow(ntw, sol_vec=u, stop_condition="tol", iter=50, friction_model="nikuradse", From ac54e41d24024f336fb90ec7054fcd75e5c46750 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 4 Mar 2024 13:45:58 +0100 Subject: [PATCH 102/237] solve WARNINGs --- src/pandapipes/converter/stanet/preparing_steps.py | 4 ++-- src/pandapipes/networks/simple_gas_networks.py | 7 ++++--- src/pandapipes/pf/pipeflow_setup.py | 4 ++-- .../test/pipeflow_internals/test_inservice.py | 4 ++-- src/pandapipes/toolbox.py | 10 +++++----- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index 43c190ffb..378c4dccf 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -422,11 +422,11 @@ def dist_on_line(row): connections["line_geo"] = pd.Series("", index=connections.index, dtype=object) main_connection = connections.CLIENTTYP == 2 if np.any(main_connection): - connections.line_geo.loc[main_connection] = \ + connections.loc[main_connection, 'line_geo'] = \ pipe_geodata.loc[connections.SNUM.loc[main_connection].values].values house_connection = connections.CLIENTTYP == 38 if np.any(house_connection): - connections.line_geo.loc[house_connection] = \ + connections.loc[house_connection, 'line_geo'] = \ house_pipe_geodata.loc[connections.SNUM.loc[house_connection].values].values connections["pos_on_line"] = connections.apply(dist_on_line, axis=1) # connections = connections.sort_values(["type", "SNUM"]) diff --git a/src/pandapipes/networks/simple_gas_networks.py b/src/pandapipes/networks/simple_gas_networks.py index 55065d650..558d27a1e 100644 --- a/src/pandapipes/networks/simple_gas_networks.py +++ b/src/pandapipes/networks/simple_gas_networks.py @@ -3,8 +3,9 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import os -from pandapipes.io.file_io import from_json + from pandapipes import pp_dir, drop_junctions +from pandapipes.io.file_io import from_json from pandapipes.networks.nw_aux import log_result_upon_loading try: @@ -265,6 +266,6 @@ def schutterwald(include_houses=True, max_length_house_conn_m=None): drop_junctions(net, net.sink.junction.values) if max_length_house_conn_m is not None: - net.pipe.in_service.loc[(net.pipe.type=="house_connection") & - (net.pipe.length_km > max_length_house_conn_m / 1000)] = False + net.pipe.loc[(net.pipe.type == "house_connection") & + (net.pipe.length_km > max_length_house_conn_m / 1000), 'in_service'] = False return net diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 4e14205d2..85d9f978b 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -668,7 +668,7 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): reduced_node_lookup = None nodes_connected = get_lookup(net, "node", "active_" + mode) branches_connected = get_lookup(net, "branch", "active_" + mode) - if np.alltrue(nodes_connected): + if np.all(nodes_connected): net["_lookups"]["node_from_to_active_" + mode] = copy.deepcopy( get_lookup(net, "node", "from_to")) net["_lookups"]["node_index_active_" + mode] = copy.deepcopy( @@ -682,7 +682,7 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): tbl: reduced_node_lookup[idx_lookup[idx_lookup != -1]] for tbl, idx_lookup in node_idx_lookup.items()} els["node"] = nodes_connected - if np.alltrue(branches_connected): + if np.all(branches_connected): net["_lookups"]["branch_from_to_active_" + mode] = copy.deepcopy( get_lookup(net, "branch", "from_to")) active_pit["branch"] = np.copy(branch_pit) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 31fc269d5..99e2fbd93 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -391,7 +391,7 @@ def test_connectivity_heat3(complex_heat_connectivity_grid, use_numba): def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): net = copy.deepcopy(complex_heat_connectivity_grid) - net.pipe.in_service.loc[[7, 8]] = True + net.pipe.loc[[7, 8], 'in_service'] = True j_new = pandapipes.create_junction(net, 1, 320.15) pandapipes.create_pipe_from_parameters(net, 8, j_new, 0.1, 0.1, alpha_w_per_m2k=5) @@ -406,7 +406,7 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): @pytest.mark.parametrize("use_numba", [True, False]) def test_connectivity_heat5(complex_heat_connectivity_grid, use_numba): net = copy.deepcopy(complex_heat_connectivity_grid) - net.pipe.in_service.loc[[7, 8]] = True + net.pipe.loc[[7, 8], 'in_service'] = True j_from, j_to = pandapipes.create_junctions(net, 2, 1, 320.15) diff --git a/src/pandapipes/toolbox.py b/src/pandapipes/toolbox.py index e0b5d2565..e70a4bf71 100644 --- a/src/pandapipes/toolbox.py +++ b/src/pandapipes/toolbox.py @@ -600,12 +600,12 @@ def get_internal_tables_pandas(net, convert_types=True): if convert_types: # TODO: replace types with a version retrieved from get_pit_lookup, but before, the types # need to be defined properly inside the files! - node_table["NODE_TYPE"].replace(pit_types, inplace=True) - node_table["NODE_TYPE_T"].replace(pit_types, inplace=True) - node_table["TABLE_IDX"].replace(node_table_lookup["n2t"], inplace=True) + node_table.replace({"NODE_TYPE": pit_types}, inplace=True) + node_table.replace({"NODE_TYPE_T": pit_types}, inplace=True) + node_table.replace( {"TABLE_IDX": node_table_lookup["n2t"]}, inplace=True) - branch_table["BRANCH_TYPE"].replace(pit_types, inplace=True) - branch_table["TABLE_IDX"].replace(branch_table_lookup["n2t"], inplace=True) + branch_table.replace({"BRANCH_TYPE": pit_types}, inplace=True) + branch_table.replace({"TABLE_IDX": branch_table_lookup["n2t"]}, inplace=True) for col in int_cols + bool_cols: for tbl in (node_table, branch_table): From c3111681abf910784049f78d031171a56bbd9e90 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 18 Mar 2024 10:47:51 +0100 Subject: [PATCH 103/237] check for element validity now optional, removed **multi** from docs --- src/pandapipes/topology/graph_searches.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py index 89e063e26..4c2cf1dd2 100644 --- a/src/pandapipes/topology/graph_searches.py +++ b/src/pandapipes/topology/graph_searches.py @@ -117,7 +117,7 @@ def unsupplied_junctions(net, mg=None, slacks=None, respect_valves=True): return not_supplied -def elements_on_path(mg, path, element="pipe"): +def elements_on_path(mg, path, element="pipe", check_element_validity=True): """ Finds all elements that connect a given path of junctions. @@ -126,10 +126,9 @@ def elements_on_path(mg, path, element="pipe"): **path** (list) - List of connected junctions. - **element** (string, "l") - element type of type BranchComponent + **element** (string, "pipe") - element type of type BranchComponent - **multi** (boolean, True) - True: Applied on a NetworkX MultiGraph - False: Applied on a NetworkX Graph + **check_element_validity** (boolean, True) - Check if element is a valid pandapipes table_name OUTPUT: **elements** (list) - Returns a list of all elements on the path. @@ -141,9 +140,10 @@ def elements_on_path(mg, path, element="pipe"): elements = top.elements_on_path(mg, [4, 5, 6]) """ - table_names = get_all_branch_component_table_names() - if element not in table_names: - raise ValueError("Invalid element type %s" % element) + if check_element_validity: + table_names = get_all_branch_component_table_names() + if element not in table_names: + raise ValueError("Invalid element type %s" % element) if isinstance(mg, nx.MultiGraph): return [edge[1] for b1, b2 in zip(path, path[1:]) for edge in mg.get_edge_data(b1, b2).keys() if edge[0] == element] From cb968ee210649716f4360da5a5598a9fcb4bb651 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 13:35:11 +0100 Subject: [PATCH 104/237] created vectorized checks in bulk heat consumer creation --- src/pandapipes/create.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index bfd3f801f..b9b18a419 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1740,15 +1740,15 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, :Example: >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, qext_w=2000) """ - # TODO: change this to vectorized form - if deltat_k is not None or treturn_k is not None: + if np.any(pd.notnull(deltat_k)) or np.any(pd.notnull(treturn_k)): raise NotImplementedError("The models for consumers with fixed temperature difference or " "fixed return temperature are not implemented yet.") - if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) - + (treturn_k is None) !=2): - raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " - r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") - if deltat_k is not None and treturn_k is not None: + if np.any(pd.isnull(controlled_mdot_kg_per_s) + pd.isnull(qext_w) + pd.isnull(deltat_k) + + pd.isnull(treturn_k) != 2): + raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None" + r"for each heat consumer.") + if np.any(pd.notnull(deltat_k) & pd.notnull(treturn_k)): raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " r"flow temperature is independent of the heat consumer model.") From dedfbae03042443a2161d5843d714be10a02e85c Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 18 Mar 2024 14:08:46 +0100 Subject: [PATCH 105/237] new function plot_pressure_profile new function calc_distance_to_junctions --- src/pandapipes/plotting/pipeflow_results.py | 100 ++++++++++++++++++ .../test/topology/test_graph_searches.py | 11 ++ src/pandapipes/topology/graph_searches.py | 36 +++++++ 3 files changed, 147 insertions(+) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index 520c2cb5f..f7a02cdb9 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -5,6 +5,8 @@ import pandapipes.topology as top import pandas as pd +import matplotlib.pyplot as plt +from itertools import combinations def pressure_profile_to_junction_geodata(net): @@ -36,3 +38,101 @@ def pressure_profile_to_junction_geodata(net): return pd.DataFrame({"x": dist.loc[junctions].values, "y": net.res_junction.p_bar.loc[junctions].values}, index=junctions) + + +def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_controller=True, xlabel="Distance from Slack in km", + ylabel="Pressure in bar", x0=0, pipe_color="tab:grey", pc_color="r", + junction_colors="tab:blue", junction_size=3, pipes=None, **kwargs): + """Plot the pressure profile depending on the distance from the x0_junction (slack). + + Parameters + ---------- + net : pp.PandapowerNet + net including pipeflow results + ax : matplotlib.axes, optional + axis to plot to, by default None + x0_junctions : Any[list[int], pd.Index[int]], optional + list of junction indices which should be at position x0. If None, all in service slack junctions are considered, + by default None + plot_pressure_controller : bool, optional + Whether vertical lines should be plotted to display the pressure drop of the pressure controller, + by default True + xlabel : str, optional + xlable of the figure, by default "Distance from Slack in km" + ylabel : str, optional + ylable of the figure, by default "Pressure in bar" + x0 : int, optional + x0_junction position at the xaxis, by default 0 + pipe_color : str, optional + color used to plot the pipes, by default "tab:grey" + pc_color : str, optional + color used to plot the pressure controller, by default "r" + junction_colors : [str, dict[int, str]], optional + colors used to plot the junctions. Can be passed as string (to give all junctions the same color), + or as dict, by default "tab:blue" + junction_size : int, optional + size of junction representations, by default 3 + pipes : Any[list[int], pd.Index[int]], optional + list of pipe indices which should be plottet. If None, all pipes are plotted, by default None + + Returns + ------- + matplotlib.axes + axis of the plot + + """ + if ax is None: + plt.figure(facecolor="white", dpi=120) + ax = plt.gca() + if not net.converged: + raise ValueError("no results in this pandapipes network") + if pipes is None: + pipes = net.pipe.index + if x0_junctions is None: + x0_junctions = net.ext_grid[net.ext_grid.in_service].junction.values.tolist() + + d = top.calc_distance_to_junctions(net, x0_junctions) + for pix, pipe in net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)].iterrows(): + if pipe.from_junction not in d.index: + continue + from_junction = pipe.from_junction + to_junction = pipe.to_junction + x = [x0 + d.at[from_junction], x0 + d.at[to_junction]] + try: + y = [net.res_junction.p_bar.at[from_junction], net.res_junction.p_bar.at[to_junction]] + except Exception as e: + raise UserWarning(e) # todo: logger + if "linewidth" in kwargs: + ax.plot(x, y, color=pipe_color, **kwargs) + else: + ax.plot(x, y, linewidth=1, color=pipe_color, **kwargs) + if junction_colors is not None: + if isinstance(junction_colors, str): + junction_colors = {b: junction_colors for b in net.junction.index} + for junction, x, y in zip((from_junction, to_junction), x, y): + if junction in junction_colors: + ax.plot(x, y, 'o', color=junction_colors[junction], ms=junction_size) + kwargs = {k: v for k, v in kwargs.items() if not k == "label"} + + # pressure controller geodata + if plot_pressure_controller: + pc_table = "press_control" + if pc_table in net.keys(): + pressure_controller = net[pc_table].query('in_service') + for pcid, pc in pressure_controller.iterrows(): + pc_junctions = [pc[b_col] for b_col in ('from_junction', 'to_junction') if b_col in pc.index] + if any([b not in d.index.values or b not in net.res_junction.index.values for b in pc_junctions]): + print('cannot add press_control %d to plot' % pcid) # todo: logger + #logger.info('cannot add press_control %d to plot' % pcid) + continue + + for bi, bj in combinations(pc_junctions, 2): + pc_coords = ([x0 + d.loc[bi], x0 + d.loc[bj]], + [net.res_junction.at[bi, 'p_bar'], net.res_junction.at[bj, 'p_bar']]) + ax.plot(*pc_coords, color=pc_color, + **{k: v for k, v in kwargs.items() if not k == "color"}) + if xlabel is not None: + ax.set_xlabel(xlabel) + if ylabel is not None: + ax.set_ylabel(ylabel) + return ax diff --git a/src/pandapipes/test/topology/test_graph_searches.py b/src/pandapipes/test/topology/test_graph_searches.py index d9d2c0edc..1d92b780b 100644 --- a/src/pandapipes/test/topology/test_graph_searches.py +++ b/src/pandapipes/test/topology/test_graph_searches.py @@ -22,6 +22,13 @@ def test_connected_components(): assert len(list(top.connected_components(mg))) == 8 +def test_calc_distance_to_junctions(): + net = nw.gas_versatility() + egs = net.ext_grid.junction + assert top.calc_distance_to_junctions(net, egs, respect_status_valves=True).sum() == 30.93 + assert top.calc_distance_to_junctions(net, egs, respect_status_valves=False).sum() == 26.96 + + def test_unsupplied_buses_with_in_service(): net = nw.gas_versatility() assert top.unsupplied_junctions(net) == set() @@ -41,3 +48,7 @@ def test_elements_on_path(): with pytest.raises(ValueError) as exception_info: top.elements_on_path(mg, path, element="source") assert str(exception_info.value) == "Invalid element type source" + + +if __name__ == "__main__": + pytest.main([__file__]) diff --git a/src/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py index 4c2cf1dd2..cd2cf9331 100644 --- a/src/pandapipes/topology/graph_searches.py +++ b/src/pandapipes/topology/graph_searches.py @@ -79,6 +79,42 @@ def calc_minimum_distance_to_junctions(net, junctions, notravjunctions=None, nog return pd.Series(nx.single_source_dijkstra_path_length(mg, junction)) +def calc_distance_to_junctions(net, junctions, respect_status_valves=True, notravjunctions=None, nogojunctions=None, weight="weight"): + """ + Calculates the shortest distance between every source junction and all junctions connected to it. + + INPUT: + **net** (pandapipesNet) - Variable that contains a pandapipes network. + + **junctions** (integer) - Index of the source junctions. + + + OPTIONAL: + **respect_status_valve** (boolean, True) - Flag whether the "opened" column shall be considered and out\ + of service valves neglected. + + **nogojunctions** (integer/list, None) - nogojunctions are not being considered + + **notravjunctions** (integer/list, None) - lines connected to these junctions are not being + considered + **weight** (string, None) – Edge data key corresponding to the edge weight + + OUTPUT: + **dist** - Returns a pandas series with containing all distances to the source junction + in km. If weight=None dist is the topological distance (int). + + EXAMPLE: + import pandapipes.topology as top + + dist = top.calc_distance_to_junctions(net, [5, 6]) + + """ + g = create_nxgraph(net, respect_status_valves=respect_status_valves, nogojunctions=nogojunctions, + notravjunctions=notravjunctions) + d = nx.multi_source_dijkstra_path_length(g, set(junctions), weight=weight) + return pd.Series(d) + + def unsupplied_junctions(net, mg=None, slacks=None, respect_valves=True): """ Finds junctions, that are not connected to an external grid. From 8a839ea0d91fbdb66a004f9dcd70840bda654bdb Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 14:54:34 +0100 Subject: [PATCH 106/237] added more tests to heat consumer creation --- src/pandapipes/create.py | 7 +- .../api/test_components/test_heat_consumer.py | 133 ++++++++++++++++-- 2 files changed, 126 insertions(+), 14 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index b9b18a419..931f665bd 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1743,8 +1743,11 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, if np.any(pd.notnull(deltat_k)) or np.any(pd.notnull(treturn_k)): raise NotImplementedError("The models for consumers with fixed temperature difference or " "fixed return temperature are not implemented yet.") - if np.any(pd.isnull(controlled_mdot_kg_per_s) + pd.isnull(qext_w) + pd.isnull(deltat_k) - + pd.isnull(treturn_k) != 2): + check_vars = [controlled_mdot_kg_per_s, qext_w, deltat_k, treturn_k] + var_sums = np.zeros([4, len(from_junctions)]) + for i, cv in enumerate(check_vars): + var_sums[i] = np.full_like(from_junctions, pd.isnull(cv)).astype(int) + if np.any(np.sum(var_sums, axis=0) != 2): raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " r"'qext_w' and 'deltat_k' or 'treturn_k' different from None" r"for each heat consumer.") diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 95a969f9d..b30bd7a6e 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -3,41 +3,150 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import copy +import pytest + import pandapipes import pandas as pd import numpy as np -def test_heat_consumer_equivalence(): - net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") +MDOT = [3, 2] +QEXT = [150000, 75000] - mdot = [3, 2] - qext = [150000, 75000] +@pytest.fixture(scope="module") +def simple_heat_net(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, system=["flow"] * 3 + ["return"] * 3) pandapipes.create_pipes_from_parameters( net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 ) - pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 400, type='pt') + return net + + +def test_heat_consumer_equivalence(simple_heat_net): + net = copy.deepcopy(simple_heat_net) + net2 = copy.deepcopy(simple_heat_net) + juncs = net.junction.index + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, + controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) + pandapipes.pipeflow(net, mode="all") + + j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) + pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) + pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) + pandapipes.pipeflow(net2, mode="all") - net2 = copy.deepcopy(net) + assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) + + +def test_heat_consumer_equivalence_bulk(simple_heat_net): + net = copy.deepcopy(simple_heat_net) + net2 = copy.deepcopy(simple_heat_net) + juncs = net.junction.index - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - qext_w=qext[1]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, qext_w=QEXT) pandapipes.pipeflow(net, mode="all") j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) - pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, mdot, diameter_m=0.1022) - pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, qext) + pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) + pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) pandapipes.pipeflow(net2, mode="all") assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) +def test_heat_consumer_not_implemented_model(simple_heat_net): + net = copy.deepcopy(simple_heat_net) + juncs = net.junction.index + + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], deltat_k=20) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], + deltat_k=20) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], treturn_k=390) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], + treturn_k=390) + + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + deltat_k=[20, None]) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + with pytest.raises(NotImplementedError): + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + treturn_k=[390, None]) + + +@pytest.mark.xfail(reason="Can only be tested once models for deltat_k and treturn_k" + " are implemented for heat consumers.") +def test_heat_consumer_creation_not_allowed(simple_heat_net): + net = copy.deepcopy(simple_heat_net) + juncs = net.junction.index + with pytest.raises(AttributeError): + # check for more than 2 set parameters + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0], + treturn_k=390) + with pytest.raises(AttributeError): + # check for less than 2 set parameters + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], qext_w=None, + treturn_k=None) + with pytest.raises(AttributeError): + # check for deltat_k and treturn_k given + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, deltat_k=20, treturn_k=390) + + with pytest.raises(AttributeError): + # check for more than 2 set parameters + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + deltat_k=[30, 40], treturn_k=[390, 385]) + with pytest.raises(NotImplementedError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) + with pytest.raises(NotImplementedError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + deltat_k=[20, None]) + with pytest.raises(NotImplementedError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + with pytest.raises(NotImplementedError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + treturn_k=[390, None]) + with pytest.raises(NotImplementedError): + # check for less than 2 set parameters in all consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + treturn_k=None, controlled_mdot_kg_per_s=None) + with pytest.raises(AttributeError): + # check for deltat_k and treturn_k given + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + deltat_k=[30, 40], treturn_k=[390, 385]) + with pytest.raises(AttributeError): + # check for deltat_k and treturn_k given as single values + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + deltat_k=30, treturn_k=390) + + if __name__ == '__main__': pd.set_option("display.width", 1000) pd.set_option("display.max_columns", 45) From 4a452bee435e3c1915b17f70ba9ceafac4316f92 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 15:27:23 +0100 Subject: [PATCH 107/237] removed xfail for some heat consumer tests, small pep corrections --- src/pandapipes/create.py | 46 ++++++++++--------- .../api/test_components/test_heat_consumer.py | 40 +++++++++++----- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 931f665bd..52730e383 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -221,11 +221,11 @@ def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_ :type mdot_kg_per_s: float, default None :param init_m_stored_kg: The initially stored mass in the storage :type init_m_stored_kg: float, default None - :param min_m_stored_kg: Minimum amount of fluid that has to remain in the storage unit. (To be used - with controllers) + :param min_m_stored_kg: Minimum amount of fluid that has to remain in the storage unit. (To be + used with controllers) :type min_m_stored_kg: float - :param max_m_stored_kg: Maximum amount of fluid that can be stored in the storage unit. (To be used - with controllers) + :param max_m_stored_kg: Maximum amount of fluid that can be stored in the storage unit. (To be + used with controllers) :type max_m_stored_kg: float, default np.inf :param scaling: An optional scaling factor to be set customly :type scaling: float, default 1 @@ -1020,9 +1020,9 @@ def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_ return index -def create_heat_consumer(net, from_junction, to_junction, diameter_m, controlled_mdot_kg_per_s=None, - qext_w=None, deltat_k=None, treturn_k=None, name=None, index=None, - in_service=True, type="heat_consumer", **kwargs): +def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=None, + controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, name=None, + index=None, in_service=True, type="heat_consumer", **kwargs): """ Creates a heat consumer element in net["heat_consumer"] from heat consumer parameters. @@ -1061,13 +1061,14 @@ def create_heat_consumer(net, from_junction, to_junction, diameter_m, controlled :rtype: int :Example: - >>> create_heat_consumer(net,from_junction=0, to_junction=1, diameter_m=40e-3, qext_w=2000) + >>> create_heat_consumer(net,from_junction=0, to_junction=1, diameter_m=40e-3, qext_w=20000, + >>> controlled_mdot_kg_per_s=0.4, name="heat_consumer1") """ if deltat_k is not None or treturn_k is not None: raise NotImplementedError("The models for consumers with fixed temperature difference or " "fixed return temperature are not implemented yet.") if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) - + (treturn_k is None) !=2): + + (treturn_k is None) != 2): raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") if deltat_k is not None and treturn_k is not None: @@ -1572,7 +1573,7 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct _set_multiple_entries(net, "press_control", index, **entries, **kwargs) controlled_elsewhere = (controlled_junctions != from_junctions) \ - & (controlled_junctions != to_junctions) + & (controlled_junctions != to_junctions) if np.any(controlled_elsewhere): controllers_warn = index[controlled_elsewhere] logger.warning("The pressure controllers %s control the pressure at junctions that they are" @@ -1642,8 +1643,9 @@ def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_p return index -def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, loss_coefficient=0, - name=None, index=None, in_service=True, type="heat_exchanger", **kwargs): +def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, + loss_coefficient=0, name=None, index=None, in_service=True, + type="heat_exchanger", **kwargs): """ Convenience function for creating many heat exchangers at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1670,7 +1672,8 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w highest already existing index is selected and counted onwards for the amount of heat \ exchangers created. :type index: Iterable(str) or str, default None - :param in_service: True if the heat exchangers are in service or False if they are out of service + :param in_service: True if the heat exchangers are in service or False if they are out of \ + service :type in_service: Iterable(bool) or bool, default True :param type: Not used yet :type type: Iterable(str) or str, default "heat exchanger" @@ -1696,8 +1699,8 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w return index -def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, - controlled_mdot_kg_per_s=None, qext_w=None, deltat_k=None, treturn_k=None, +def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w=None, + controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, name=None, index=None, in_service=True, type="heat_consumer", **kwargs): """ Creates several heat consumer elements in net["heat_consumer"] from heat consumer parameters. @@ -1738,7 +1741,8 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, :rtype: int :Example: - >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, qext_w=2000) + >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, + >>> qext_w=20000, controlled_mdot_kg_per_s=[0.5, 0.9]) """ if np.any(pd.notnull(deltat_k)) or np.any(pd.notnull(treturn_k)): raise NotImplementedError("The models for consumers with fixed temperature difference or " @@ -1748,9 +1752,9 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, for i, cv in enumerate(check_vars): var_sums[i] = np.full_like(from_junctions, pd.isnull(cv)).astype(int) if np.any(np.sum(var_sums, axis=0) != 2): - raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " - r"'qext_w' and 'deltat_k' or 'treturn_k' different from None" - r"for each heat consumer.") + raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " + r"'qext_w' and 'deltat_k' or 'treturn_k' different from Nonefor each" + r" heat consumer.") if np.any(pd.notnull(deltat_k) & pd.notnull(treturn_k)): raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " r"flow temperature is independent of the heat consumer model.") @@ -1771,8 +1775,8 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, def create_fluid_from_lib(net, name, overwrite=True): """ Creates a fluid from library (if there is an entry) and sets net["fluid"] to this value. - Currently, existing fluids in the library are: "hgas", "lgas", "hydrogen", "methane", "water","biomethane_pure", - "biomethane_treated", "air". + Currently, existing fluids in the library are: "hgas", "lgas", "hydrogen", "methane", + "water","biomethane_pure", "biomethane_treated", "air". :param net: The net for which this fluid should be created :type net: pandapipesNet diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index b30bd7a6e..d5a1dc023 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -94,9 +94,32 @@ def test_heat_consumer_not_implemented_model(simple_heat_net): treturn_k=[390, None]) +def test_heat_consumer_creation_not_allowed(simple_heat_net): + net = copy.deepcopy(simple_heat_net) + juncs = net.junction.index + + with pytest.raises(AttributeError): + # check for less than 2 set parameters + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, + controlled_mdot_kg_per_s=MDOT[0], qext_w=None, + treturn_k=None) + with pytest.raises(AttributeError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, + controlled_mdot_kg_per_s=MDOT, qext_w=[QEXT[0], None]) + with pytest.raises(AttributeError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + controlled_mdot_kg_per_s=[MDOT[0], None]) + with pytest.raises(AttributeError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + controlled_mdot_kg_per_s=None) + + @pytest.mark.xfail(reason="Can only be tested once models for deltat_k and treturn_k" " are implemented for heat consumers.") -def test_heat_consumer_creation_not_allowed(simple_heat_net): +def test_heat_consumer_creation_not_allowed_2(simple_heat_net): net = copy.deepcopy(simple_heat_net) juncs = net.junction.index with pytest.raises(AttributeError): @@ -104,11 +127,6 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0], treturn_k=390) - with pytest.raises(AttributeError): - # check for less than 2 set parameters - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=None, - treturn_k=None) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, deltat_k=20, treturn_k=390) @@ -117,23 +135,23 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): # check for more than 2 set parameters pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=[30, 40], treturn_k=[390, 385]) - with pytest.raises(NotImplementedError): + with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) - with pytest.raises(NotImplementedError): + with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, deltat_k=[20, None]) - with pytest.raises(NotImplementedError): + with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) - with pytest.raises(NotImplementedError): + with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=[390, None]) - with pytest.raises(NotImplementedError): + with pytest.raises(AttributeError): # check for less than 2 set parameters in all consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=None, controlled_mdot_kg_per_s=None) From 1bd09d079c85c8398ff6bfaeb4c1eab85f01fb5e Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 15:29:15 +0100 Subject: [PATCH 108/237] small pep fixes --- src/pandapipes/create.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 52730e383..5dc012b6c 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1750,9 +1750,9 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= check_vars = [controlled_mdot_kg_per_s, qext_w, deltat_k, treturn_k] var_sums = np.zeros([4, len(from_junctions)]) for i, cv in enumerate(check_vars): - var_sums[i] = np.full_like(from_junctions, pd.isnull(cv)).astype(int) + var_sums[i] = np.full_like(from_junctions, pd.isnull(cv)).astype(np.int32) if np.any(np.sum(var_sums, axis=0) != 2): - raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " + raise AttributeError(r"Define exactly two variables from 'controlled_mdot_kg_per_s', " r"'qext_w' and 'deltat_k' or 'treturn_k' different from Nonefor each" r" heat consumer.") if np.any(pd.notnull(deltat_k) & pd.notnull(treturn_k)): From 4a57b248c06ce19834a432f64f8d8f3f2e1573f9 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 15:35:42 +0100 Subject: [PATCH 109/237] remodec temperature lift function from heat consumer --- .../component_models/heat_consumer_component.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 62169ecb1..824833389 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -228,18 +228,3 @@ def extract_results(cls, net, options, branch_results, mode): extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode) - - @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 From a3a2ebd8cab03f2b4f948f2ed10c9e1e06c34258 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 18 Mar 2024 15:39:51 +0100 Subject: [PATCH 110/237] import fix --- src/pandapipes/component_models/heat_consumer_component.py | 7 ++++--- .../component_models/heat_exchanger_component.py | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 824833389..5fef84f36 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -8,8 +8,8 @@ from pandapipes.component_models import get_fluid, \ BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, VINIT, ALPHA, QEXT, \ - RHO, TEXT, JAC_DERIV_DP1, JAC_DERIV_DV, JAC_DERIV_DP, LOAD_VEC_BRANCHES, TL +from pandapipes.idx_branch import (D, AREA, VINIT, ALPHA, QEXT, RHO, TEXT, JAC_DERIV_DP1, + JAC_DERIV_DV, JAC_DERIV_DP, LOAD_VEC_BRANCHES) from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -137,7 +137,8 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo # f, t = idx_lookups[cls.table_name()] # hs_pit = branch_pit[f:t, :] # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) - # hs_pit[mask_t_return, TINIT_OUT] = hs_pit[mask_t_return, TINIT_OUT] - hs_pit[mask_t_return, DELTAT] + # hs_pit[mask_t_return, TINIT_OUT] = (hs_pit[mask_t_return, TINIT_OUT] + # - hs_pit[mask_t_return, DELTAT]) # # # @classmethod diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index 92c8b4b9b..5dc36d0cb 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -81,7 +81,6 @@ def extract_results(cls, net, options, branch_results, mode): extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode) - @classmethod def get_component_input(cls): """ From 181abb6ffc5d39495a4b0dea428ad7db8902af48 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 19 Mar 2024 08:19:03 +0100 Subject: [PATCH 111/237] adapt coveragerc to omit paths in src --- .coveragerc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.coveragerc b/.coveragerc index b0c066e41..827e6359f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -11,6 +11,6 @@ exclude_lines = pragma: no cover omit = - pandapipes/test/* - pandapipes/plotting/geo.py - pandapipes/converter/stanet/data_cleaning.py + src/pandapipes/test/* + src/pandapipes/plotting/geo.py + src/pandapipes/converter/stanet/data_cleaning.py From 1f815e64a719b692859c13011de6f4db70089722 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Fri, 22 Mar 2024 11:24:59 +0100 Subject: [PATCH 112/237] removed some unnecessary lines of code --- src/pandapipes/plotting/pipeflow_results.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index f7a02cdb9..91dffe4b3 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -92,11 +92,10 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control x0_junctions = net.ext_grid[net.ext_grid.in_service].junction.values.tolist() d = top.calc_distance_to_junctions(net, x0_junctions) - for pix, pipe in net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)].iterrows(): - if pipe.from_junction not in d.index: + pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)] + for from_junction, to_junction in zip(pipe_table.from_junction, pipe_table.to_junction): + if from_junction not in d.index: continue - from_junction = pipe.from_junction - to_junction = pipe.to_junction x = [x0 + d.at[from_junction], x0 + d.at[to_junction]] try: y = [net.res_junction.p_bar.at[from_junction], net.res_junction.p_bar.at[to_junction]] From db1ca1a5ea1a85275776f0082bb209dad5b74d58 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 25 Mar 2024 15:37:49 +0100 Subject: [PATCH 113/237] vectorized plotting --- src/pandapipes/plotting/pipeflow_results.py | 58 +++++++-------------- src/pandapipes/topology/graph_searches.py | 6 --- 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index 91dffe4b3..ed4d9f67b 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -7,6 +7,7 @@ import pandas as pd import matplotlib.pyplot as plt from itertools import combinations +import numpy as np def pressure_profile_to_junction_geodata(net): @@ -42,7 +43,7 @@ def pressure_profile_to_junction_geodata(net): def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_controller=True, xlabel="Distance from Slack in km", ylabel="Pressure in bar", x0=0, pipe_color="tab:grey", pc_color="r", - junction_colors="tab:blue", junction_size=3, pipes=None, **kwargs): + junction_color="tab:blue", junction_size=3, pipes=None, **kwargs): """Plot the pressure profile depending on the distance from the x0_junction (slack). Parameters @@ -67,7 +68,7 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control color used to plot the pipes, by default "tab:grey" pc_color : str, optional color used to plot the pressure controller, by default "r" - junction_colors : [str, dict[int, str]], optional + junction_color : [str, dict[int, str]], optional colors used to plot the junctions. Can be passed as string (to give all junctions the same color), or as dict, by default "tab:blue" junction_size : int, optional @@ -93,43 +94,22 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control d = top.calc_distance_to_junctions(net, x0_junctions) pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)] - for from_junction, to_junction in zip(pipe_table.from_junction, pipe_table.to_junction): - if from_junction not in d.index: - continue - x = [x0 + d.at[from_junction], x0 + d.at[to_junction]] - try: - y = [net.res_junction.p_bar.at[from_junction], net.res_junction.p_bar.at[to_junction]] - except Exception as e: - raise UserWarning(e) # todo: logger - if "linewidth" in kwargs: - ax.plot(x, y, color=pipe_color, **kwargs) - else: - ax.plot(x, y, linewidth=1, color=pipe_color, **kwargs) - if junction_colors is not None: - if isinstance(junction_colors, str): - junction_colors = {b: junction_colors for b in net.junction.index} - for junction, x, y in zip((from_junction, to_junction), x, y): - if junction in junction_colors: - ax.plot(x, y, 'o', color=junction_colors[junction], ms=junction_size) - kwargs = {k: v for k, v in kwargs.items() if not k == "label"} - - # pressure controller geodata - if plot_pressure_controller: - pc_table = "press_control" - if pc_table in net.keys(): - pressure_controller = net[pc_table].query('in_service') - for pcid, pc in pressure_controller.iterrows(): - pc_junctions = [pc[b_col] for b_col in ('from_junction', 'to_junction') if b_col in pc.index] - if any([b not in d.index.values or b not in net.res_junction.index.values for b in pc_junctions]): - print('cannot add press_control %d to plot' % pcid) # todo: logger - #logger.info('cannot add press_control %d to plot' % pcid) - continue - - for bi, bj in combinations(pc_junctions, 2): - pc_coords = ([x0 + d.loc[bi], x0 + d.loc[bj]], - [net.res_junction.at[bi, 'p_bar'], net.res_junction.at[bj, 'p_bar']]) - ax.plot(*pc_coords, color=pc_color, - **{k: v for k, v in kwargs.items() if not k == "color"}) + + x = np.array([d.loc[pipe_table.from_junction].values, d.loc[pipe_table.to_junction].values]) + x0 + y = np.array([net.res_junction.p_bar.loc[pipe_table.from_junction].values, net.res_junction.p_bar.loc[pipe_table.to_junction].values]) + linewidth = kwargs.get("linewidth", 1) + ax.plot(x, y, linewidth=linewidth, color=pipe_color, **kwargs) + + x = d.values + y = net.res_junction.p_bar.loc[d.index] + ax.plot(x, y, 'o', color=junction_color, ms=junction_size) + + if plot_pressure_controller and ("press_control" in net.keys()): + pressure_controller = net.press_control.query('in_service') + x = np.array([d.loc[pressure_controller.from_junction].values, d.loc[pressure_controller.to_junction].values]) + x0 + y = np.array([net.res_junction.p_bar.loc[pressure_controller.from_junction].values, net.res_junction.p_bar.loc[pressure_controller.to_junction].values]) + ax.plot(x, y, color=pc_color, **{k: v for k, v in kwargs.items() if not k == "color"}) + if xlabel is not None: ax.set_xlabel(xlabel) if ylabel is not None: diff --git a/src/pandapipes/topology/graph_searches.py b/src/pandapipes/topology/graph_searches.py index cd2cf9331..a81ef952a 100644 --- a/src/pandapipes/topology/graph_searches.py +++ b/src/pandapipes/topology/graph_searches.py @@ -186,9 +186,3 @@ def elements_on_path(mg, path, element="pipe", check_element_validity=True): else: return [mg.get_edge_data(b1, b2)["key"][1] for b1, b2 in zip(path, path[1:]) if mg.get_edge_data(b1, b2)["key"][0] == element] - - -if __name__ == '__main__': - import pandapipes.networks as nw - net = nw.gas_meshed_delta() - dist = calc_minimum_distance_to_junctions(net, net.ext_grid.junction.values) From 9b7734bc3ce18d90a7b81e06eaa20252e7e4e5b5 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 26 Mar 2024 08:41:21 +0100 Subject: [PATCH 114/237] removed unused import --- src/pandapipes/plotting/pipeflow_results.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index ed4d9f67b..d278fd9a7 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -6,7 +6,6 @@ import pandapipes.topology as top import pandas as pd import matplotlib.pyplot as plt -from itertools import combinations import numpy as np From 26eff8867a7c24c7f8d8286e1c3bd6c9dbf7bb00 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 26 Mar 2024 08:56:49 +0100 Subject: [PATCH 115/237] added x0 to junction coordinates --- src/pandapipes/plotting/pipeflow_results.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index d278fd9a7..c3810043b 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -99,7 +99,7 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control linewidth = kwargs.get("linewidth", 1) ax.plot(x, y, linewidth=linewidth, color=pipe_color, **kwargs) - x = d.values + x = d.values + x0 y = net.res_junction.p_bar.loc[d.index] ax.plot(x, y, 'o', color=junction_color, ms=junction_size) From 63b08777063f8b4d886820a5b5153e19421398fb Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:34:00 +0100 Subject: [PATCH 116/237] remove TOUTINIT from heat_exchanger as not required --- src/pandapipes/component_models/heat_exchanger_component.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index 92c8b4b9b..58c5e0dad 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -58,7 +58,6 @@ def create_pit_branch_entries(cls, net, branch_pit): 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[:, TOUTINIT] = 307 @classmethod def extract_results(cls, net, options, branch_results, mode): From 2cf7c1e85eda1674757117979fe7731c0dca8459 Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:50:19 +0100 Subject: [PATCH 117/237] - adding max_iter_hyd and max_iter_therm instead of iter - decreasing the default tolerance --- .../converter/stanet/preparing_steps.py | 2 +- src/pandapipes/pf/pipeflow_setup.py | 10 +- src/pandapipes/pipeflow.py | 4 +- .../release_control_test_network.py | 12 +- .../test_components/test_circ_pump_mass.py | 5 +- .../test_circ_pump_pressure.py | 5 +- .../api/test_components/test_compressor.py | 5 +- .../test/api/test_components/test_ext_grid.py | 54 ++++-- .../api/test_components/test_flow_control.py | 16 +- .../test_components/test_heat_exchanger.py | 5 +- .../api/test_components/test_mass_storage.py | 3 +- .../api/test_components/test_pipe_results.py | 5 +- .../test_components/test_pressure_control.py | 3 +- .../test/api/test_components/test_pump.py | 19 ++- .../test/api/test_components/test_valve.py | 3 +- .../test/api/test_convert_format.py | 21 ++- .../test/api/test_special_networks.py | 16 +- src/pandapipes/test/api/test_time_series.py | 7 +- .../test/converter/test_stanet_converter.py | 15 +- .../test/multinet/test_control_multinet.py | 46 +++-- .../multinet/test_time_series_multinet.py | 7 +- src/pandapipes/test/networks/test_networks.py | 9 +- .../pipeflow_openmodelica_comparison.py | 8 +- .../test_heat_transfer_openmodelica.py | 48 +++++- .../test_water_openmodelica.py | 158 ++++++++++++++---- .../test/pipeflow_internals/test_inservice.py | 131 ++++++++++----- .../test_non_convergence.py | 6 +- .../test/pipeflow_internals/test_options.py | 6 +- .../test_pipeflow_analytic_comparison.py | 39 ++++- .../pipeflow_internals/test_pipeflow_modes.py | 18 +- .../pipeflow_internals/test_time_series.py | 6 +- .../pipeflow_internals/test_update_matrix.py | 3 +- .../test/plotting/test_pipeflow_results.py | 6 +- .../test/stanet_comparison/test_gas_stanet.py | 105 +++++++++--- .../stanet_comparison/test_water_stanet.py | 121 +++++++++++--- src/pandapipes/test/test_toolbox.py | 6 +- 36 files changed, 690 insertions(+), 243 deletions(-) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index 378c4dccf..ae8c9faeb 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -201,7 +201,7 @@ def get_net_params(net, stored_data): else: pandapipes.set_user_pf_options( net, friction_model=known_friction_models[net_params["friction_model"]], - iter=net_params["max_iterations"] + max_iter_hyd=net_params["max_iterations"], max_iter_therm=net_params["max_iteration"] ) if net_params["compress_model"] != "linear": logger.warning("The compressibility model %s is not implemented in pandapipes, which might " diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 85d9f978b..a91a989db 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -33,8 +33,9 @@ logger = logging.getLogger(__name__) -default_options = {"friction_model": "nikuradse", "tol_p": 1e-4, "tol_m": 1e-4, - "tol_T": 1e-3, "tol_res": 1e-3, "iter": 10, "error_flag": False, "alpha": 1, +default_options = {"friction_model": "nikuradse", "tol_p": 1e-5, "tol_m": 1e-5, + "tol_T": 1e-3, "tol_res": 1e-3, "max_iter_hyd": 10, "max_iter_therm": 10, + "error_flag": False, "alpha": 1, "nonlinear_method": "constant", "mode": "hydraulics", "ambient_temperature": 293, "check_connectivity": True, "max_iter_colebrook": 10, "only_update_hydraulic_matrix": False, @@ -212,7 +213,10 @@ def init_options(net, local_parameters): Those are the options that can be set and their default values: - - **iter** (int): 10 - If the simulation is terminated after a certain amount of \ + - **max_iter_hyd** (int): 10 - If the hydraulics simulation is terminated after a certain amount of \ + iterations, this is the number of iterations. + + - **max_iter_therm** (int): 10 - If the thermal simulation is terminated after a certain amount of \ iterations, this is the number of iterations. - **tol_p** (float): 1e-4 - The relative tolerance for the pressure. A result is accepted \ diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index c1b9699cf..0a341282b 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -115,7 +115,7 @@ def pipeflow(net, sol_vec=None, **kwargs): def hydraulics(net): max_iter, nonlinear_method, tol_p, tol_m, tol_res = get_net_options( - net, "iter", "nonlinear_method", "tol_p", "tol_m", "tol_res") + net, "max_iter_hyd", "nonlinear_method", "tol_p", "tol_m", "tol_res") # Start of nonlinear loop # --------------------------------------------------------------------------------------------- @@ -158,7 +158,7 @@ def hydraulics(net): def heat_transfer(net): max_iter, nonlinear_method, tol_t, tol_res = get_net_options( - net, "iter", "nonlinear_method", "tol_T", "tol_res") + net, "max_iter_therm", "nonlinear_method", "tol_T", "tol_res") # Start of nonlinear loop # --------------------------------------------------------------------------------------------- diff --git a/src/pandapipes/test/api/release_cycle/release_control_test_network.py b/src/pandapipes/test/api/release_cycle/release_control_test_network.py index c8fbae0d5..028ce2629 100644 --- a/src/pandapipes/test/api/release_cycle/release_control_test_network.py +++ b/src/pandapipes/test/api/release_cycle/release_control_test_network.py @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) path = os.path.join(pp_dir, "test", "api", "old_versions") -def release_control_test_network(save=False): +def release_control_test_network(max_iter_hyd, save=False): # empty net net = pp.create_empty_network("net", add_stdtypes=False) @@ -139,14 +139,14 @@ def release_control_test_network(save=False): const_sink.initial_run = False const_source.initial_run = False - pp.pipeflow(net) + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) if save: pp.to_json(net, os.path.join(path, 'example_%s.json' % pp.__version__)) return net -def release_control_test_network_water(save=False): +def release_control_test_network_water(max_iter_hyd, save=False): # empty net net = pp.create_empty_network("net", add_stdtypes=False) @@ -244,14 +244,14 @@ def release_control_test_network_water(save=False): # time series add_ts_controllers(net) - pp.pipeflow(net) + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) if save: pp.to_json(net, os.path.join(path, 'example_%s_water.json' % pp.__version__)) return net -def release_control_test_network_gas(save=False): +def release_control_test_network_gas(max_iter_hyd, save=False): # empty net net = pp.create_empty_network("net", add_stdtypes=False) @@ -338,7 +338,7 @@ def release_control_test_network_gas(save=False): # time series add_ts_controllers(net) - pp.pipeflow(net) + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) if save: pp.to_json(net, os.path.join(path, 'example_%s_gas.json' % pp.__version__)) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index ae30750cc..51ff4943c 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -34,7 +34,10 @@ def test_circulation_pump_constant_mass(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", + max_iter_hyd = 4 if use_numba else 4 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + stop_condition="tol", friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index c85469c5a..bb24286f2 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -35,7 +35,10 @@ def test_circulation_pump_constant_pressure(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", + max_iter_hyd = 8 if use_numba else 8 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + stop_condition="tol", friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_compressor.py b/src/pandapipes/test/api/test_components/test_compressor.py index 791422022..996f8914a 100644 --- a/src/pandapipes/test/api/test_components/test_compressor.py +++ b/src/pandapipes/test/api/test_components/test_compressor.py @@ -28,7 +28,8 @@ def test_compressor_pressure_ratio(use_numba): c2 = pandapipes.create_compressor(net, j5, j4, pressure_ratio=br1) # reverse flow -> bypass c3 = pandapipes.create_compressor(net, j5, j6, pressure_ratio=br3) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, use_numba=use_numba) net.res_junction["abs_p_bar"] = net.res_junction.p_bar + \ p_correction_height_air(net.junction.height_m) @@ -50,7 +51,7 @@ def test_compressor_pressure_ratio(use_numba): br_new = 1.3 net.compressor.loc[c1, "pressure_ratio"] = br_new - pandapipes.pipeflow(net) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) net.res_junction["abs_p_bar"] = net.res_junction.p_bar + \ p_correction_height_air(net.junction.height_m) diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index bf1ea4f8f..a78edc713 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -35,7 +35,8 @@ def test_ext_grid_sorting(use_numba): pandapipes.create_sink(net, j6, mdot_kg_per_s=0.1) pandapipes.create_sink(net, j2, mdot_kg_per_s=0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert np.isclose(net.res_ext_grid.at[0, "mdot_kg_per_s"], -0.12, atol=1e-12, rtol=1e-12) assert np.isclose(net.res_ext_grid.at[1, "mdot_kg_per_s"], -0.1, atol=1e-12, rtol=1e-12) @@ -59,7 +60,9 @@ def test_p_type(use_numba): pandapipes.create_ext_grid(net, 0, p_bar=5, t_k=285.15, type="p") pandapipes.create_sink(net, 1, mdot_kg_per_s=1) pandapipes.create_fluid_from_lib(net, name="water") - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -90,7 +93,10 @@ def test_t_type_single_pipe(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 6 if use_numba else 6 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -108,7 +114,10 @@ def test_t_type_single_pipe(use_numba): pandapipes.create_pipe_from_parameters(net2, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 12 if use_numba else 12 + pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -146,7 +155,11 @@ def test_t_type_tee(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + + max_iter_hyd = 4 if use_numba else 4 + max_iter_therm = 5 if use_numba else 5 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -171,10 +184,10 @@ def test_t_type_tee(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=70, friction_model="nikuradse", + pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) - temp2 = net2.res_junction.t_k.values temp_diff = np.abs(1 - temp / temp2) @@ -212,9 +225,11 @@ def test_t_type_tee_2zu_2ab(use_numba): alpha_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, alpha_w_per_m2k=5) - pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=5, friction_model="nikuradse", + max_iter_hyd = 4 if use_numba else 4 + max_iter_therm = 5 if use_numba else 5 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -243,7 +258,8 @@ def test_t_type_tee_2zu_2ab(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=5, friction_model="nikuradse", + pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -283,9 +299,11 @@ def test_t_type_tee_2zu_2ab2(use_numba): alpha_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, alpha_w_per_m2k=5) - pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=20, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 6 if use_numba else 6 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -314,7 +332,8 @@ def test_t_type_tee_2zu_2ab2(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=20, friction_model="nikuradse", + pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -356,7 +375,11 @@ def test_t_type_tee_2zu_2ab3(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", + + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 6 if use_numba else 6 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) @@ -385,7 +408,8 @@ def test_t_type_tee_2zu_2ab3(use_numba): alpha_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) - pandapipes.pipeflow(net2, stop_condition="tol", iter=10, friction_model="nikuradse", + pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, mode="all", use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_flow_control.py b/src/pandapipes/test/api/test_components/test_flow_control.py index 262acb9de..026532d59 100644 --- a/src/pandapipes/test/api/test_components/test_flow_control.py +++ b/src/pandapipes/test/api/test_components/test_flow_control.py @@ -25,7 +25,10 @@ def test_flow_control_simple_heat(use_numba): pandapipes.create_sink(net, j8, 3) - pandapipes.pipeflow(net, mode="all", use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values, [2, 1]) @@ -33,7 +36,8 @@ def test_flow_control_simple_heat(use_numba): j_new = pandapipes.create_junctions(net, 2, pn_bar=5, tfluid_k=360) pandapipes.create_flow_control(net, j_new[0], j_new[1], 2, 0.1) - pandapipes.pipeflow(net, mode="all", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba, check_connectivity=True) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values[:2], [2, 1]) @@ -56,7 +60,9 @@ def test_flow_control_simple_gas(use_numba): pandapipes.create_sinks(net, [j3, j4, j5, j7, j8], [0.02, 0.04, 0.03, 0.04, 0.02]) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba) assert np.allclose(net.res_pipe.loc[[p12, p23, p34, p45, p56, p58, p67], "mdot_from_kg_per_s"], [0.15, 0.12, 0.08, 0.01, 0.01, -0.01, 0.04]) @@ -79,7 +85,9 @@ def test_flow_control_simple_gas_two_eg(use_numba): pandapipes.create_sinks(net, [j2, j3], [0.02, 0.04]) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba) assert np.allclose(net.res_pipe.loc[[p12, p34], "mdot_from_kg_per_s"], [0.05, -0.01]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values, [0.03]) diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index bd1483200..d485cf901 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -29,7 +29,10 @@ def test_heat_exchanger(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 2 if use_numba else 2 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + stop_condition="tol", friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_mass_storage.py b/src/pandapipes/test/api/test_components/test_mass_storage.py index 9b8707702..d7774e2ae 100644 --- a/src/pandapipes/test/api/test_components/test_mass_storage.py +++ b/src/pandapipes/test/api/test_components/test_mass_storage.py @@ -22,7 +22,8 @@ def test_mass_storage(use_numba): pandapipes.create_mass_storage(net, j2, 0.1) pandapipes.create_mass_storage(net, j3, -0.2) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.isclose(net.res_ext_grid["mdot_kg_per_s"], 0.1) diff --git a/src/pandapipes/test/api/test_components/test_pipe_results.py b/src/pandapipes/test/api/test_components/test_pipe_results.py index 0c19372b0..60c978e40 100644 --- a/src/pandapipes/test/api/test_components/test_pipe_results.py +++ b/src/pandapipes/test/api/test_components/test_pipe_results.py @@ -37,7 +37,8 @@ def test_pipe_velocity_results(use_numba): name="natural_gas", fluid_type="gas", viscosity=11.93e-6, heat_capacity=2185, compressibility=1, der_compressibility=0, density=0.82752 )) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 5 if use_numba else 5 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba) @@ -60,7 +61,7 @@ def test_pipe_velocity_results(use_numba): name="natural_gas", fluid_type="gas", viscosity=11.93e-6, heat_capacity=2185, compressibility=1, der_compressibility=0, density=0.82752 )) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_pressure_control.py b/src/pandapipes/test/api/test_components/test_pressure_control.py index 67fc624e3..a2984dbb8 100644 --- a/src/pandapipes/test/api/test_components/test_pressure_control.py +++ b/src/pandapipes/test/api/test_components/test_pressure_control.py @@ -34,7 +34,8 @@ def test_pressure_control_from_measurement_parameters(use_numba): pandapipes.create_fluid_from_lib(net, "lgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_components/test_pump.py b/src/pandapipes/test/api/test_components/test_pump.py index d59b57328..aeac043b7 100644 --- a/src/pandapipes/test/api/test_components/test_pump.py +++ b/src/pandapipes/test/api/test_components/test_pump.py @@ -35,7 +35,8 @@ def test_pump_from_measurement_parameteres(use_numba): pandapipes.create_fluid_from_lib(net, "lgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -77,7 +78,8 @@ def test_pump_from_regression_parameteres(use_numba): pandapipes.create_fluid_from_lib(net, "lgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -115,7 +117,8 @@ def test_pump_from_std_type(use_numba): pandapipes.create_fluid_from_lib(net, "lgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -153,7 +156,8 @@ def test_pump_bypass_on_reverse_flow(use_numba): pandapipes.create_fluid_from_lib(net, "hgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -183,7 +187,8 @@ def test_pump_bypass_high_vdot(use_numba): pandapipes.create_fluid_from_lib(net, "hgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=30, friction_model="nikuradse", + max_iter_hyd = 5 if use_numba else 5 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -215,7 +220,9 @@ def test_compression_power(use_numba): _ = pandapipes.create_ext_grid(net, junction=j0, p_bar=4, t_k=293.15) _ = pandapipes.create_sink(net, junction=j3, mdot_kg_per_s=0.05) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + use_numba=use_numba) # Local ambiental (atmospheric) pressure p_amb_bar_j1 = net["_pit"]['node'][1][PAMB] diff --git a/src/pandapipes/test/api/test_components/test_valve.py b/src/pandapipes/test/api/test_components/test_valve.py index 03a2cc797..0b326ef66 100644 --- a/src/pandapipes/test/api/test_components/test_valve.py +++ b/src/pandapipes/test/api/test_components/test_valve.py @@ -46,7 +46,8 @@ def test_valve(use_numba): pandapipes.create_fluid_from_lib(net, "lgas", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=10, friction_model="nikuradse", + max_iter_hyd = 8 if use_numba else 7 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", mode="hydraulics", transient=False, nonlinear_method="automatic", tol_p=1e-8, tol_m=1e-8, use_numba=use_numba) diff --git a/src/pandapipes/test/api/test_convert_format.py b/src/pandapipes/test/api/test_convert_format.py index 08fbe0b36..59380702f 100644 --- a/src/pandapipes/test/api/test_convert_format.py +++ b/src/pandapipes/test/api/test_convert_format.py @@ -27,15 +27,21 @@ def test_convert_format(pp_version, use_numba): if version.parse(pp_version) >= version.parse(minimal_version_two_nets): names = ["_gas", "_water"] - net_gas = release_control_test_network_gas() - net_water = release_control_test_network_water() + net_gas = release_control_test_network_gas(max_iter_hyd=5) + net_water = release_control_test_network_water(max_iter_hyd=10) else: names = [""] - net_old = release_control_test_network() + net_old = release_control_test_network(max_iter_hyd=10) for name in names: - if "_gas" in name: net_ref = net_gas - elif "_water" in name: net_ref = net_water - else: net_ref = net_old + if "_gas" in name: + net_ref = net_gas + max_iter_hyd = 5 if use_numba else 5 + elif "_water" in name: + net_ref = net_water + max_iter_hyd = 10 if use_numba else 10 + else: + net_ref = net_old + max_iter_hyd = 10 if use_numba else 10 filename = os.path.join(folder, "example_%s%s.json" % (pp_version, name)) if not os.path.isfile(filename): raise ValueError("File for %s grid of version %s does not exist" % (name, pp_version)) @@ -48,7 +54,8 @@ def test_convert_format(pp_version, use_numba): convert_format(net) try: pp.pipeflow(net, run_control="controller" in net and len(net.controller) > 0, - use_numba=use_numba) + use_numba=use_numba, max_iter_hyd=max_iter_hyd) + except: raise UserWarning("Can not run pipe flow in %s network " "saved with pandapipes version %s" % (name, pp_version)) diff --git a/src/pandapipes/test/api/test_special_networks.py b/src/pandapipes/test/api/test_special_networks.py index 23ddd7727..90e63497b 100644 --- a/src/pandapipes/test/api/test_special_networks.py +++ b/src/pandapipes/test/api/test_special_networks.py @@ -27,7 +27,9 @@ def test_one_node_net(use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + + max_iter_hyd = 1 if use_numba else 1 + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.isclose(net.res_ext_grid.values + net.res_sink.values - net.res_source.values, 0) @@ -36,7 +38,7 @@ def test_one_node_net(use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.isclose(net.res_ext_grid.values + net.res_sink.values - net.res_source.values, 0) @@ -58,7 +60,8 @@ def test_two_node_net(use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 1 if use_numba else 1 + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.all(np.isclose(net.res_ext_grid.values + net.res_sink.values - net.res_source.values, np.zeros((2, 1)))) @@ -72,7 +75,7 @@ def test_two_node_net(use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.all(np.isclose(net.res_ext_grid.values + net.res_sink.values - net.res_source.values, np.zeros((2, 1)))) @@ -96,7 +99,8 @@ def test_random_net_and_one_node_net(create_test_net, use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) net = copy.deepcopy(create_test_net) @@ -106,7 +110,7 @@ def test_random_net_and_one_node_net(create_test_net, use_numba): create_ext_grid(net, j, 1, 298.15) create_sink(net, j, 0.01) create_source(net, j, 0.02) - pandapipes.pipeflow(net, use_numba=use_numba) + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) assert np.isclose( net.res_ext_grid.values[-1] + net.res_sink.values[-1] - net.res_source.values[-1], 0) diff --git a/src/pandapipes/test/api/test_time_series.py b/src/pandapipes/test/api/test_time_series.py index 3d0fbf0a8..b565cbaae 100644 --- a/src/pandapipes/test/api/test_time_series.py +++ b/src/pandapipes/test/api/test_time_series.py @@ -11,8 +11,11 @@ def person_run_fct(net, sol_vec=None, **kwargs): net.res_junction.p_bar.values[:] = 15. net = ntw.water_strand_net_2pumps() - pps.pipeflow(net, mode='all') + max_iter_hyd = 3 + max_iter_therm = 1 + pps.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) assert all(np.isclose(net.res_junction.p_bar.values, [7., 25.02309542, 24.73038636, 22.11851835, 16.70728061, 16.23637491])) - run_timeseries(net, time_steps=range(10), mode='all', run=person_run_fct) + run_timeseries(net, time_steps=range(10), max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode='all', run=person_run_fct) assert all(net.output_writer.iat[0, 0].np_results['res_junction.p_bar'].flatten() == 15.) diff --git a/src/pandapipes/test/converter/test_stanet_converter.py b/src/pandapipes/test/converter/test_stanet_converter.py index 83bd32d54..6734d1ebb 100644 --- a/src/pandapipes/test/converter/test_stanet_converter.py +++ b/src/pandapipes/test/converter/test_stanet_converter.py @@ -31,7 +31,8 @@ def test_mini_exampelonia(): assert os.path.isfile(mininet_path), f"test file not found: {mininet_path}" net = stanet_to_pandapipes(mininet_path, add_layers=False) - pandapipes.pipeflow(net) + max_iter_hyd = 2 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) res_p_pp = net.res_junction.p_bar res_p_stanet = net.junction.p_stanet @@ -55,7 +56,8 @@ def test_mini_exampelonia_not_stanetlike(): assert os.path.isfile(mininet_path), f"test file not found: {mininet_path}" net = stanet_to_pandapipes(mininet_path, stanet_like_valves=False) - pandapipes.pipeflow(net) + max_iter_hyd = 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) assert net.converged @@ -67,7 +69,8 @@ def test_mini_exampelonia_stanetlike(): assert os.path.isfile(mininet_path), f"test file not found: {mininet_path}" net = stanet_to_pandapipes(mininet_path, stanet_like_valves=True, add_layers=False) - pandapipes.pipeflow(net) + max_iter_hyd = 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) assert net.converged @@ -79,7 +82,8 @@ def test_mini_exampelonia_sliders_open(): assert os.path.isfile(mininet_path), f"test file not found: {mininet_path}" net = stanet_to_pandapipes(mininet_path, add_layers=False) - pandapipes.pipeflow(net) + max_iter_hyd = 2 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) assert net.converged @@ -91,6 +95,7 @@ def test_mini_exampelonia_sliders_closed(): assert os.path.isfile(mininet_path), f"test file not found: {mininet_path}" net = stanet_to_pandapipes(mininet_path, add_layers=False) - pandapipes.pipeflow(net) + max_iter_hyd = 2 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) assert net.converged diff --git a/src/pandapipes/test/multinet/test_control_multinet.py b/src/pandapipes/test/multinet/test_control_multinet.py index 8bfc88fa9..88eb711fa 100644 --- a/src/pandapipes/test/multinet/test_control_multinet.py +++ b/src/pandapipes/test/multinet/test_control_multinet.py @@ -61,7 +61,8 @@ def test_p2g_single(get_gas_example, get_power_example_simple): eta = 0.5 P2GControlMultiEnergy(mn, p2g_id_el, p2g_id_gas, efficiency=eta) - run_control(mn) + max_iter_hyd = 7 + run_control(mn, max_iter_hyd=max_iter_hyd) # nets must not be changed assert mn.nets["power"] == net_power @@ -77,7 +78,7 @@ def test_p2g_single(get_gas_example, get_power_example_simple): # check scaling functionality scaling_factor = 0.5 net_power.load.loc[p2g_id_el, 'scaling'] = scaling_factor - run_control(mn) + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.isclose(net_gas.source.at[p2g_id_gas, "mdot_kg_per_s"], p_p2g_el * scaling_factor / (net_gas.fluid.get_property('hhv') * 3.6) * eta) assert net_power.load.at[p2g_id_el, "p_mw"] == p_p2g_el # has to be still the same @@ -104,7 +105,8 @@ def test_g2p_single(get_gas_example, get_power_example_simple): eta = 0.4 G2PControlMultiEnergy(mn, g2p_id_el, g2p_id_gas, efficiency=eta, element_type_power="sgen") - run_control(mn) + max_iter_hyd = 4 + run_control(mn, max_iter_hyd=max_iter_hyd) # nets must not be changed assert mn.nets["power"] == net_power @@ -120,7 +122,7 @@ def test_g2p_single(get_gas_example, get_power_example_simple): # check scaling functionality scaling_factor = 0.5 net_gas.sink.loc[g2p_id_gas, 'scaling'] = scaling_factor - run_control(mn) + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.isclose(net_power.sgen.at[g2p_id_el, "p_mw"], gas_cons_kg_per_s * scaling_factor * net_gas.fluid.get_property("hhv") * 3.6 * eta) @@ -150,8 +152,8 @@ def test_g2g_single(get_gas_example): eta = 0.65 GasToGasConversion(mn, g2g_id_cons, g2g_id_prod, efficiency=eta, name_gas_net_from='hgas_net', name_gas_net_to='hydrogen_net') - - run_control(mn) + max_iter_hyd = 7 + run_control(mn, max_iter_hyd=max_iter_hyd) fluid1 = pandapipes.get_fluid(net_gas1) fluid2 = pandapipes.get_fluid(net_gas2) @@ -171,7 +173,8 @@ def test_g2g_single(get_gas_example): # check scaling functionality scaling_factor = 0.5 net_gas1.sink.loc[g2g_id_cons, 'scaling'] = scaling_factor - run_control(mn) + max_iter_hyd = 8 + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.isclose(net_gas2.source.at[g2g_id_prod, "mdot_kg_per_s"], (gas1_cons_kg_per_s * scaling_factor * fluid1.all_properties["hhv"].value / fluid2.all_properties["hhv"].value) * eta) @@ -201,8 +204,9 @@ def test_p2g_multiple(get_gas_example, get_power_example_simple): eta = 0.5 P2GControlMultiEnergy(mn, p2g_ids_el, p2g_ids_gas, efficiency=eta) + max_iter_hyd = 8 # run control should read/write values with .loc - run_control(mn) + run_control(mn, max_iter_hyd=max_iter_hyd) # nets must not be changed assert mn.nets["power"] == net_power @@ -219,7 +223,9 @@ def test_p2g_multiple(get_gas_example, get_power_example_simple): # check scaling functionality scaling_factor = 0.5 net_power.load.loc[p2g_ids_el, 'scaling'] = scaling_factor - run_control(mn) + + max_iter_hyd = 6 + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.allclose(net_gas.source.loc[p2g_ids_gas, "mdot_kg_per_s"], p_p2g_el * scaling_factor / (net_gas.fluid.get_property('hhv') * 3.6) * eta) @@ -250,8 +256,8 @@ def test_g2p_multiple(get_gas_example, get_power_example_simple): # add coupling controller eta = 0.4 G2PControlMultiEnergy(mn, g2p_ids_el, g2p_ids_gas, efficiency=eta, element_type_power="sgen") - - run_control(mn) + max_iter_hyd = 4 + run_control(mn, max_iter_hyd=max_iter_hyd) # nets must not be changed assert mn.nets["power"] == net_power @@ -268,7 +274,7 @@ def test_g2p_multiple(get_gas_example, get_power_example_simple): # check scaling functionality scaling_factor = 0.5 net_gas.sink.loc[g2p_ids_gas, 'scaling'] = scaling_factor - run_control(mn) + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.allclose(net_power.sgen.loc[g2p_ids_el, "p_mw"], gas_cons_kg_per_s * scaling_factor * fluid.all_properties["hhv"].value @@ -303,8 +309,8 @@ def test_g2g_multiple(get_gas_example): eta = 0.65 GasToGasConversion(mn, g2g_ids_cons, g2g_ids_prod, efficiency=eta, name_gas_net_from='hgas_net', name_gas_net_to='hydrogen_net') - - run_control(mn) + max_iter_hyd = 6 + run_control(mn, max_iter_hyd=max_iter_hyd) fluid1 = pandapipes.get_fluid(net_gas1) fluid2 = pandapipes.get_fluid(net_gas2) @@ -325,7 +331,7 @@ def test_g2g_multiple(get_gas_example): # check scaling functionality scaling_factor = 0.5 net_gas1.sink.loc[g2g_ids_cons, 'scaling'] = scaling_factor - run_control(mn) + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.allclose(net_gas2.source.loc[g2g_ids_prod, "mdot_kg_per_s"], gas1_cons_kg_per_s * scaling_factor * fluid1.all_properties["hhv"].value / fluid2.all_properties["hhv"].value * eta) @@ -354,7 +360,8 @@ def test_const_p2g_control(get_gas_example, get_power_example_simple): ConstControl(net_power, 'load', 'p_mw', 1) ConstControl(net_power, 'sgen', 'p_mw', 0) - run_control(mn) + max_iter_hyd = 8 + run_control(mn, max_iter_hyd=max_iter_hyd) assert np.all(net_power.res_load.p_mw.values == power_load) assert np.all(net_gas.res_sink.values == flow_gas) @@ -380,7 +387,8 @@ def test_run_control_wo_controller(get_gas_example, get_power_example_simple): add_nets_to_multinet(mn, power=net_power, gas=net_gas) - run_control(mn) + max_iter_hyd = 8 + run_control(mn, max_iter_hyd=max_iter_hyd) def test_p2g_single_run_parameter(get_gas_example, get_power_example_simple): @@ -403,8 +411,10 @@ def test_p2g_single_run_parameter(get_gas_example, get_power_example_simple): eta = 0.5 P2GControlMultiEnergy(mn, p2g_id_el, p2g_id_gas, efficiency=eta) + max_iter_hyd = 7 run_control(mn, ctrl_variables={"nets": {"power": {"run": runpp_with_mark}, - "gas": {"run": pipeflow_with_mark}}}) + "gas": {"run": pipeflow_with_mark}}}, + max_iter_hyd=max_iter_hyd) assert net_power["mark"] == "runpp" assert net_gas["mark"] == "pipeflow" diff --git a/src/pandapipes/test/multinet/test_time_series_multinet.py b/src/pandapipes/test/multinet/test_time_series_multinet.py index 63ac5348b..845815b36 100644 --- a/src/pandapipes/test/multinet/test_time_series_multinet.py +++ b/src/pandapipes/test/multinet/test_time_series_multinet.py @@ -65,7 +65,8 @@ def test_time_series_p2g_control(get_gas_example, get_power_example_simple): ('res_sgen', 'p_mw')] ow_power = OutputWriter(net_power, range(10), log_variables=log_variables) - run_timeseries(mn, range(10)) + max_iter_hyd = 5 + run_timeseries(mn, range(10), max_iter_hyd=max_iter_hyd) gas_res = ow_gas.np_results power_res = ow_power.np_results @@ -123,7 +124,9 @@ def test_time_series_p2g_control_run_parameter(get_gas_example, get_power_exampl ('res_sgen', 'p_mw')] OutputWriter(net_power, range(10), log_variables=log_variables) - run_timeseries(mn, range(1), run={"power": runpp_with_mark, "gas": pipeflow_with_mark}) + max_iter_hyd = 5 + run_timeseries(mn, range(1), max_iter_hyd=max_iter_hyd, + run={"power": runpp_with_mark, "gas": pipeflow_with_mark}) assert net_power.mark == "runpp" assert net_gas.mark == "pipeflow" diff --git a/src/pandapipes/test/networks/test_networks.py b/src/pandapipes/test/networks/test_networks.py index 0aae9dea8..1c6032509 100644 --- a/src/pandapipes/test/networks/test_networks.py +++ b/src/pandapipes/test/networks/test_networks.py @@ -9,20 +9,23 @@ def test_schutterwald(): net = networks.schutterwald(True, None) - pp.pipeflow(net) + max_iter_hyd = 3 + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) assert net.converged net2 = networks.schutterwald(False, None) assert net2.sink.empty assert len(net2.pipe.loc[net2.pipe.type == "house_connection"]) == 0 - pp.pipeflow(net2) + max_iter_hyd = 2 + pp.pipeflow(net2, max_iter_hyd=max_iter_hyd) assert net2.converged net3 = networks.schutterwald(True, 30) assert len(net3.sink) == 1506 assert net3.pipe.loc[net3.pipe.in_service & (net3.pipe.type == "house_connection"), "length_km"].max() <= 0.03 - pp.pipeflow(net3) + max_iter_hyd = 3 + pp.pipeflow(net3, max_iter_hyd=max_iter_hyd) assert net3.converged diff --git a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py index 53b830f39..c70eaa1c0 100644 --- a/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py +++ b/src/pandapipes/test/openmodelica_comparison/pipeflow_openmodelica_comparison.py @@ -20,8 +20,9 @@ def pipeflow_openmodelica_comparison(net, log_results=True, friction_model='colebrook', + max_iter_hyd=10, max_iter_therm=10, mode='hydraulics', only_update_hydraulic_matrix=False, - use_numba=True): + use_numba=True, **kwargs): """ Comparison of the calculations of OpenModelica and pandapipes. @@ -40,9 +41,10 @@ def pipeflow_openmodelica_comparison(net, log_results=True, friction_model='cole :return: p_diff, v_diff_abs :rtype: one-dimensional ndarray with axis labels """ - pp.pipeflow(net, stop_condition="tol", iter=100, tol_p=1e-7, tol_m=1e-7, + pp.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + tol_p=1e-7, tol_m=1e-7, friction_model=friction_model, mode=mode, use_numba=use_numba, - only_update_hydraulic_matrix=only_update_hydraulic_matrix) + only_update_hydraulic_matrix=only_update_hydraulic_matrix, **kwargs) logger.debug(net.res_junction) logger.debug(net.res_pipe) diff --git a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py index b7ccd6dc6..03c7ab523 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py @@ -23,8 +23,12 @@ @pytest.mark.parametrize("use_numba", [True, False]) def test_case_delta(use_numba, log_results=False): net = nw.heat_transfer_delta() + max_iter_hyd = 10 if use_numba else 10 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.05) assert np.all(v_diff_abs < 0.05) @@ -33,8 +37,12 @@ def test_case_delta(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_delta_2sinks(use_numba, log_results=False): net = nw.heat_transfer_delta_2sinks() + max_iter_hyd = 10 if use_numba else 10 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -43,8 +51,12 @@ def test_case_delta_2sinks(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_heights(use_numba, log_results=False): net = nw.heat_transfer_heights() + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.0065) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -53,8 +65,12 @@ def test_case_heights(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe(use_numba, log_results=False): net = nw.heat_transfer_one_pipe() + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -63,8 +79,12 @@ def test_case_one_pipe(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_source(use_numba, log_results=False): net = nw.heat_transfer_one_source() + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.04) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -73,8 +93,12 @@ def test_case_one_source(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_section_variation(use_numba, log_results=False): net = nw.heat_transfer_section_variation() + max_iter_hyd = 10 if use_numba else 10 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) # all values of temp_diff_mean are zero except one with about 0.025 assert np.all(temp_diff_mean < 0.03) assert np.all(p_diff < 0.022) @@ -84,8 +108,12 @@ def test_case_section_variation(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_t_cross(use_numba, log_results=False): net = nw.heat_transfer_t_cross() + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -94,8 +122,12 @@ def test_case_t_cross(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_two_pipes(use_numba, log_results=False): net = nw.heat_transfer_two_pipes() + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 2 if use_numba else 2 p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( - net, log_results, mode="all", use_numba=use_numba) + net, log_results, + max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) diff --git a/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py index 7f9c54827..da8de0c4d 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_water_openmodelica.py @@ -25,7 +25,9 @@ @pytest.mark.parametrize("use_numba", [True, False]) def test_case_combined_mixed_pc(use_numba, log_results=False): net = nw.water_combined_mixed() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 11 if use_numba else 11 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -33,7 +35,9 @@ def test_case_combined_mixed_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_combined_mixed_sj(use_numba, log_results=False): net = nw.water_combined_mixed(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 11 if use_numba else 11 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -42,7 +46,11 @@ def test_case_combined_mixed_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_combined_versatility_pc(use_numba, log_results=False): net = nw.water_combined_versatility() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 14 if use_numba else 14 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.04) # only in one place the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -50,7 +58,11 @@ def test_case_combined_versatility_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_combined_versatility_sj(use_numba, log_results=False): net = nw.water_combined_versatility(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 14 if use_numba else 14 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.04) # only in one place the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -60,7 +72,10 @@ def test_case_combined_versatility_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_delta_pc(use_numba, log_results=False): net = nw.water_meshed_delta() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 16 if use_numba else 16 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -68,7 +83,10 @@ def test_case_meshed_delta_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_delta_sj(use_numba, log_results=False): net = nw.water_meshed_delta(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 16 if use_numba else 16 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -77,7 +95,10 @@ def test_case_meshed_delta_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.water_meshed_2valves() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 19 if use_numba else 19 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -85,7 +106,10 @@ def test_case_meshed_2valves_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_sj(use_numba, log_results=False): net = nw.water_meshed_2valves(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 19 if use_numba else 19 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -94,7 +118,10 @@ def test_case_meshed_2valves_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_pumps_pc(use_numba, log_results=False): net = nw.water_meshed_pumps() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 8 if use_numba else 8 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.02) # in two places the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -102,7 +129,10 @@ def test_case_meshed_pumps_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_pumps_sj(use_numba, log_results=False): net = nw.water_meshed_pumps(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 8 if use_numba else 8 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.02) # in two places the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -111,7 +141,10 @@ def test_case_meshed_pumps_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_heights_pc(use_numba, log_results=False): net = nw.water_meshed_heights() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 11 if use_numba else 11 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -119,7 +152,10 @@ def test_case_meshed_heights_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_heights_sj(use_numba, log_results=False): net = nw.water_meshed_heights(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 11 if use_numba else 11 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -129,7 +165,10 @@ def test_case_meshed_heights_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_1_pc(use_numba, log_results=False): net = nw.water_one_pipe1() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -137,7 +176,10 @@ def test_case_one_pipe_1_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_1_sj(use_numba, log_results=False): net = nw.water_one_pipe1(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -146,7 +188,10 @@ def test_case_one_pipe_1_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_2_pc(use_numba, log_results=False): net = nw.water_one_pipe2() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -154,7 +199,10 @@ def test_case_one_pipe_2_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_2_sj(use_numba, log_results=False): net = nw.water_one_pipe2(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -163,7 +211,10 @@ def test_case_one_pipe_2_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_3_pc(use_numba, log_results=False): net = nw.water_one_pipe3() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -171,7 +222,10 @@ def test_case_one_pipe_3_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_one_pipe_3_sj(use_numba, log_results=False): net = nw.water_one_pipe3(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -181,7 +235,10 @@ def test_case_one_pipe_3_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_cross3ext_pc(use_numba, log_results=False): net = nw.water_strand_cross() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 16 if use_numba else 16 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -189,7 +246,10 @@ def test_case_strand_net_cross3ext_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_cross3ext_sj(use_numba, log_results=False): net = nw.water_strand_cross(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 16 if use_numba else 16 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -198,7 +258,10 @@ def test_case_strand_net_cross3ext_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_pc(use_numba, log_results=False): net = nw.water_simple_strand_net() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -206,7 +269,10 @@ def test_case_strand_net_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_sj(use_numba, log_results=False): net = nw.water_simple_strand_net(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -215,7 +281,10 @@ def test_case_strand_net_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_2pipes_pc(use_numba, log_results=False): net = nw.water_strand_2pipes() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -223,7 +292,10 @@ def test_case_strand_net_2pipes_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_2pipes_sj(use_numba, log_results=False): net = nw.water_strand_2pipes(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -232,7 +304,10 @@ def test_case_strand_net_2pipes_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_2pumps_pc(use_numba, log_results=False): net = nw.water_strand_net_2pumps() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -240,7 +315,10 @@ def test_case_strand_net_2pumps_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_strand_net_2pumps_sj(use_numba, log_results=False): net = nw.water_strand_net_2pumps(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -250,7 +328,10 @@ def test_case_strand_net_2pumps_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_tcross_pc(use_numba, log_results=False): net = nw.water_tcross() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -258,7 +339,10 @@ def test_case_tcross_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_tcross_sj(use_numba, log_results=False): net = nw.water_tcross(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.02) # 2 values are greater than 0.01 assert np.all(v_diff_abs < 0.05) @@ -267,7 +351,10 @@ def test_case_tcross_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_tcross_valves_pc(use_numba, log_results=False): net = nw.water_tcross_valves() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.4) # only in one place the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -275,7 +362,10 @@ def test_case_tcross_valves_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_tcross_valves_sj(use_numba, log_results=False): net = nw.water_tcross_valves(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 0.4) # only in one place the comparison for 0.01 is not correct assert np.all(v_diff_abs < 0.05) @@ -285,7 +375,9 @@ def test_case_tcross_valves_sj(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_2eg_two_pipes_pc(use_numba, log_results=False): net = nw.water_2eg_two_pipes() - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 6 if use_numba else 6 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd=max_iter_hyd) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -293,7 +385,9 @@ def test_case_2eg_two_pipes_pc(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_2eg_two_pipes_sj(use_numba, log_results=False): net = nw.water_2eg_two_pipes(method="swamee-jain") - p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 6 if use_numba else 6 + p_diff, v_diff_abs = pipeflow_openmodelica_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 99e2fbd93..3dd27f2fc 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -9,8 +9,8 @@ import pandapipes from pandapipes.pf.pipeflow_setup import get_lookup -from pandapipes.pipeflow import logger as pf_logger from pandapipes.pipeflow import PipeflowNotConverged +from pandapipes.pipeflow import logger as pf_logger try: import pandaplan.core.pplog as logging @@ -160,7 +160,9 @@ def test_inservice_gas(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "lgas") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_pipe.loc[~net.pipe.in_service, :].values)) @@ -168,7 +170,7 @@ def test_inservice_gas(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[~net.junction.in_service].values)) oos_sinks = np.isin(net.sink.junction.values, net.junction.index[~net.junction.in_service]) \ - | ~net.sink.in_service.values + | ~net.sink.in_service.values assert np.all(np.isnan(net.res_sink.loc[oos_sinks, :].values)) assert not np.any(np.isnan(net.res_pipe.v_mean_m_per_s.loc[net.pipe.in_service].values)) @@ -193,7 +195,9 @@ def test_inservice_water(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_pipe.loc[~net.pipe.in_service, :].values)) @@ -201,7 +205,7 @@ def test_inservice_water(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[~net.junction.in_service].values)) oos_sinks = np.isin(net.sink.junction.values, net.junction.index[~net.junction.in_service]) \ - | ~net.sink.in_service.values + | ~net.sink.in_service.values assert np.all(np.isnan(net.res_sink.loc[oos_sinks, :].values)) assert not any(np.isnan(net.res_pipe.v_mean_m_per_s.loc[net.pipe.in_service].values)) @@ -229,15 +233,14 @@ def test_connectivity_hydraulic(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) assert np.all(np.isnan(net.res_junction.p_bar.loc[[2, 5, 6]].values)) assert np.all(np.isnan(net.res_pipe.loc[[1, 2, 3], :].values)) assert not np.any(np.isnan(net.res_junction.loc[[0, 1, 3, 4], :].values)) - assert not np.any(np.isnan(net.res_pipe.loc[[0, 4], - ["v_mean_m_per_s", "p_from_bar", - "p_to_bar"]].values)) + assert not np.any(np.isnan(net.res_pipe.loc[[0, 4], ["v_mean_m_per_s", "p_from_bar", "p_to_bar"]].values)) assert not np.any(np.isnan(net.res_sink.loc[[0, 2], "mdot_kg_per_s"].values)) assert np.all(np.isnan(net.res_sink.loc[[1, 3, 4], "mdot_kg_per_s"].values)) @@ -263,7 +266,8 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): pandapipes.create_fluid_from_lib(net, "water") - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + max_iter_hyd = 7 if use_numba else 7 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) pandapipes.create_junction(net, 1., 293.15) @@ -276,7 +280,7 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): pandapipes.create_sink(net, j, 0.1) - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba) active_branches = get_lookup(net, "branch", "active_hydraulics") @@ -291,14 +295,18 @@ def test_connectivity_hydraulic2(create_test_net, use_numba): assert np.all(np.isnan(net.res_junction.p_bar.loc[[7, 8, 10, 11]].values)) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=False) @pytest.mark.parametrize("use_numba", [True, False]) def test_connectivity_heat1(complex_heat_connectivity_grid, use_numba): net = copy.deepcopy(complex_heat_connectivity_grid) - pandapipes.pipeflow(net, mode="all", check_connectivity=True, use_numba=use_numba) + + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", check_connectivity=True, use_numba=use_numba) oos_juncs_hyd = {4, 5, 6, 7} oos_pipe_hyd = {5, 7, 8, 9} @@ -334,7 +342,11 @@ def test_connectivity_heat1(complex_heat_connectivity_grid, use_numba): def test_connectivity_heat2(complex_heat_connectivity_grid, use_numba): net = copy.deepcopy(complex_heat_connectivity_grid) net.pipe.at[7, "in_service"] = True - pandapipes.pipeflow(net, mode="all", check_connectivity=True, use_numba=use_numba) + + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == {4} assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -364,7 +376,10 @@ def test_connectivity_heat3(complex_heat_connectivity_grid, use_numba): net.pipe.at[5, "in_service"] = True net.valve.at[12, "opened"] = True net.junction.at[5, "in_service"] = False - pandapipes.pipeflow(net, mode="all", check_connectivity=True, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == set() assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -397,8 +412,12 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): net2 = copy.deepcopy(net) - pandapipes.pipeflow(net, mode="all", check_connectivity=True, use_numba=use_numba) - pandapipes.pipeflow(net2, mode="all", check_connectivity=False, use_numba=use_numba) + max_iter_hyd = 9 if use_numba else 9 + max_iter_therm = 5 if use_numba else 5 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", check_connectivity=True, use_numba=use_numba) + pandapipes.pipeflow(net2, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + mode="all", check_connectivity=False, use_numba=use_numba) assert pandapipes.nets_equal(net, net2, check_only_results=True) @@ -417,10 +436,14 @@ def test_connectivity_heat5(complex_heat_connectivity_grid, use_numba): net.ext_grid.loc[2, 'in_service'] = False net.ext_grid.loc[1, 'type'] = 'p' - pandapipes.pipeflow(net, check_connectivity=True, mode='all', use_numba=use_numba) + max_iter_hyd = 9 if use_numba else 9 + max_iter_therm = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + check_connectivity=True, mode='all', use_numba=use_numba) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, check_connectivity=False, mode='all', use_numba=use_numba) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + check_connectivity=False, mode='all', use_numba=use_numba) @pytest.mark.parametrize("use_numba", [True, False]) @@ -441,7 +464,8 @@ def test_exclude_unconnected_junction(use_numba): pandapipes.create_sink(net, junction=j3, mdot_kg_per_s=0.045) pandapipes.create_pipe_from_parameters(net, from_junction=j1, to_junction=j3, length_km=0.1, diameter_m=0.05) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert net.converged @@ -482,22 +506,26 @@ def check_mass_flows(net): def test_mixed_indexing_oos1(create_mixed_indexing_grid, use_numba): net = copy.deepcopy(create_mixed_indexing_grid) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) + max_iter_hyd = 4 if use_numba else 4 net.pipe.at[3, "in_service"] = False - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, use_numba=use_numba) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + max_iter_hyd = 4 if use_numba else 4 + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=False) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl)].isnull()) for tbl, oos_func @@ -511,14 +539,18 @@ def test_mixed_indexing_oos2(create_mixed_indexing_grid, use_numba): net.pipe.at[10, "in_service"] = False oos_juncs = [10, 12] + max_iter_hyd = 3 if use_numba else 3 with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + pandapipes.pipeflow(net, mode="hydraulics", + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=False) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -529,14 +561,17 @@ def test_mixed_indexing_oos3(create_mixed_indexing_grid, use_numba): net.pipe.at[7, "in_service"] = False oos_juncs = [6, 15] + max_iter_hyd = 3 if use_numba else 3 with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba, check_connectivity=False) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -547,14 +582,17 @@ def test_mixed_indexing_oos4(create_mixed_indexing_grid, use_numba): net.valve.at[2, "opened"] = False oos_juncs = [15] + max_iter_hyd = 3 if use_numba else 3 with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba, check_connectivity=False) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -565,14 +603,17 @@ def test_mixed_indexing_oos5(create_mixed_indexing_grid, use_numba): net.pipe.at[6, "in_service"] = False oos_juncs = [9, 8, 7] + max_iter_hyd = 3 if use_numba else 3 with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba, check_connectivity=False) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -583,23 +624,27 @@ def test_mixed_indexing_oos6(create_mixed_indexing_grid, use_numba): net.valve.at[3, "opened"] = False oos_juncs = [14, 6, 15, 9, 8, 7] + max_iter_hyd = 3 if use_numba else 3 with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=False) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + mode="hydraulics", use_numba=use_numba, check_connectivity=False) - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", max_iter_hyd=max_iter_hyd, + use_numba=use_numba, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) net.ext_grid.at[1, "in_service"] = False - pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, check_connectivity=True) + pandapipes.pipeflow(net, mode="hydraulics", use_numba=use_numba, + max_iter_hyd=max_iter_hyd, check_connectivity=True) assert all(np.all(net["res_" + tbl].loc[~oos_func(net, tbl, oos_juncs)].notnull()) for tbl, oos_func in all_tbls_funcs.items()) assert all(np.all(net["res_" + tbl].loc[oos_func(net, tbl, oos_juncs), - get_col_slice_null(tbl)].isnull()) + get_col_slice_null(tbl)].isnull()) for tbl, oos_func in all_tbls_funcs.items()) assert check_mass_flows(net) @@ -617,13 +662,15 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): net.ext_grid.at[ex1, 'in_service'] = False net.ext_grid.at[ex2, 'in_service'] = True - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + max_iter_hyd = 9 if use_numba else 9 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert not np.all(np.isnan(net.res_junction.p_bar.values)) assert net.converged with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, + tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged diff --git a/src/pandapipes/test/pipeflow_internals/test_non_convergence.py b/src/pandapipes/test/pipeflow_internals/test_non_convergence.py index 4c365d650..c4e7299a8 100644 --- a/src/pandapipes/test/pipeflow_internals/test_non_convergence.py +++ b/src/pandapipes/test/pipeflow_internals/test_non_convergence.py @@ -16,7 +16,8 @@ def test_pipeflow_non_convergence(use_numba): net = gas_versatility() pandapipes.get_fluid(net).add_property("molar_mass", FluidPropertyConstant(16.6)) - pandapipes.pipeflow(net, use_numba=use_numba) + max_iter_hyd = 8 if use_numba else 8 + pandapipes.pipeflow(net, use_numba=use_numba, max_iter_hyd=max_iter_hyd) for comp in net["component_list"]: table_name = comp.table_name() assert np.all(net["res_" + table_name].index == net[table_name].index) @@ -26,7 +27,8 @@ def test_pipeflow_non_convergence(use_numba): pandapipes.create_sink(net, 6, 100) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, use_numba=use_numba) + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + use_numba=use_numba) for comp in net["component_list"]: table_name = comp.table_name() diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index a5e0ce893..1129d2657 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -21,7 +21,9 @@ def test_set_user_pf_options(create_test_net, use_numba): net = copy.deepcopy(create_test_net) pandapipes.create_fluid_from_lib(net, "lgas") - necessary_options = {'mode': 'hydraulics', 'use_numba': use_numba} + max_iter_hyd = 3 if use_numba else 3 + necessary_options = {'mode': 'hydraulics', 'use_numba': use_numba, + 'max_iter_hyd': max_iter_hyd} pandapipes.pipeflow(net, **necessary_options) old_options = net._options.copy() @@ -53,6 +55,8 @@ def test_set_user_pf_options(create_test_net, use_numba): # see if user arguments overrule user_pf_options, but other user_pf_options still have the # priority pandapipes.pf.pipeflow_setup.set_user_pf_options(net, reset=True, tol_p=1e-6, tol_m=1e-6) + max_iter_hyd = 4 if use_numba else 4 + necessary_options.update({'max_iter_hyd': max_iter_hyd}) pandapipes.pipeflow(net, tol_p=1e-8, **necessary_options) assert net.user_pf_options['tol_p'] == 1e-6 assert net._options['tol_p'] == 1e-8 diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 10eddc0d9..44d85e71f 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -35,7 +35,9 @@ def test_gas_internal_nodes(use_numba): name="natural_gas", fluid_type="gas", viscosity=11.93e-6, heat_capacity=2185, compressibility=1, der_compressibility=0, density=0.82752 )) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 6 if use_numba else 6 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + stop_condition="tol", friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -89,7 +91,10 @@ def test_temperature_internal_nodes_single_pipe(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -141,7 +146,10 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 4 if use_numba else 4 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -181,7 +189,10 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -221,7 +232,10 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 6 if use_numba else 6 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -261,7 +275,10 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -303,7 +320,10 @@ def test_temperature_internal_nodes_masche_1load(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -342,7 +362,10 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): pandapipes.create_ext_grid(net, j0, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j3, mdot_kg_per_s=1) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 5 if use_numba else 5 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, friction_model="nikuradse", mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index 2e361c75d..c982dd8b4 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -42,7 +42,10 @@ def test_hydraulic_only(simple_test_net, use_numba): :rtype: """ net = copy.deepcopy(simple_test_net) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, + stop_condition="tol", friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) @@ -79,7 +82,10 @@ def test_heat_only(use_numba): pandapipes.create_fluid_from_lib(net, "water", overwrite=True) - pandapipes.pipeflow(net, stop_condition="tol", iter=70, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, + stop_condition="tol", friction_model="nikuradse", nonlinear_method="automatic", mode="all", use_numba=use_numba) ntw = pandapipes.create_empty_network("net") @@ -93,13 +99,17 @@ def test_heat_only(use_numba): pandapipes.create_fluid_from_lib(ntw, "water", overwrite=True) - pandapipes.pipeflow(ntw, stop_condition="tol", iter=50, friction_model="nikuradse", + max_iter_hyd = 3 if use_numba else 3 + pandapipes.pipeflow(ntw, max_iter_hyd=max_iter_hyd, stop_condition="tol", friction_model="nikuradse", nonlinear_method="automatic", mode="hydraulics", use_numba=use_numba) + p = ntw._pit["node"][:, PINIT] m = ntw._pit["branch"][:, MDOTINIT] u = np.concatenate((p, m)) - pandapipes.pipeflow(ntw, sol_vec=u, stop_condition="tol", iter=50, friction_model="nikuradse", + max_iter_therm = 4 if use_numba else 4 + pandapipes.pipeflow(ntw, max_iter_therm=max_iter_therm, + sol_vec=u, stop_condition="tol", friction_model="nikuradse", nonlinear_method="automatic", mode="heat", use_numba=use_numba) temp_net = net.res_junction.t_k diff --git a/src/pandapipes/test/pipeflow_internals/test_time_series.py b/src/pandapipes/test/pipeflow_internals/test_time_series.py index b49d9d770..7720c38af 100644 --- a/src/pandapipes/test/pipeflow_internals/test_time_series.py +++ b/src/pandapipes/test/pipeflow_internals/test_time_series.py @@ -154,7 +154,8 @@ def test_time_series(): time_steps = range(25) # _output_writer(net, time_steps) # , path=os.path.join(ppipe.pp_dir, 'results')) _output_writer(net, time_steps, ow_path=tempfile.gettempdir()) - run_timeseries(net, time_steps, calc_compression_power=False) + max_iter_hyd=8 + run_timeseries(net, time_steps, max_iter_hyd=max_iter_hyd, calc_compression_power = False) ow = net.output_writer.iat[0, 0] _compare_results(ow) @@ -169,7 +170,8 @@ def test_time_series_default_ow(): _prepare_grid(net) time_steps = range(25) init_default_outputwriter(net, time_steps) - run_timeseries(net, time_steps, calc_compression_power=False) + max_iter_hyd = 8 + run_timeseries(net, time_steps, max_iter_hyd=max_iter_hyd, calc_compression_power = False) ow = net.output_writer.iat[0, 0] _compare_results(ow) diff --git a/src/pandapipes/test/pipeflow_internals/test_update_matrix.py b/src/pandapipes/test/pipeflow_internals/test_update_matrix.py index e0e5ee1f4..9dfa07179 100644 --- a/src/pandapipes/test/pipeflow_internals/test_update_matrix.py +++ b/src/pandapipes/test/pipeflow_internals/test_update_matrix.py @@ -29,7 +29,8 @@ def test_update(use_numba, log_results=False): """ # before: gas_case3.json net = nw.gas_one_pipe1() - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, max_iter_hyd=max_iter_hyd, only_update_hydraulic_matrix=True) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) diff --git a/src/pandapipes/test/plotting/test_pipeflow_results.py b/src/pandapipes/test/plotting/test_pipeflow_results.py index 05fa3558e..46c71073c 100644 --- a/src/pandapipes/test/plotting/test_pipeflow_results.py +++ b/src/pandapipes/test/plotting/test_pipeflow_results.py @@ -25,7 +25,8 @@ def test_pressure_profile_to_junction_geodata(): pp.create_pipe_from_parameters(net, from_junction=j3, to_junction=j4, length_km=0.4, diameter_m=0.05) - pp.pipeflow(net) + max_iter_hyd = 3 + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) jgd = plot.pressure_profile_to_junction_geodata(net) @@ -36,7 +37,8 @@ def test_pressure_profile_to_junction_geodata(): pp.create_pipe_from_parameters(net, from_junction=j1, to_junction=j4, length_km=0.2, diameter_m=0.05, name="Pipe 1") - pp.pipeflow(net) + max_iter_hyd = 4 + pp.pipeflow(net, max_iter_hyd=max_iter_hyd) jgd = plot.pressure_profile_to_junction_geodata(net) assert jgd.y.loc[jgd.index].equals(net.res_junction.p_bar.loc[jgd.index]) assert np.isclose(jgd.x.loc[jgd.index].values, [0.0, 0.2, 0.5, 0.2]).all() \ No newline at end of file diff --git a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py index 622cbef2b..2b5aca26d 100644 --- a/src/pandapipes/test/stanet_comparison/test_gas_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_gas_stanet.py @@ -31,7 +31,10 @@ def test_case_3parallel_n(use_numba, log_results=False): :rtype: """ net = nw.gas_3parallel(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -47,7 +50,9 @@ def test_case_combined_3parallel_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_3parallel(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -65,7 +70,10 @@ def test_case_square_n(use_numba, log_results=False): :rtype: """ net = nw.gas_meshed_square(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -81,7 +89,10 @@ def test_case_square_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_meshed_square(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -98,7 +109,10 @@ def test_case_meshed_delta_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_meshed_delta() - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 13 if use_numba else 13 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -115,7 +129,10 @@ def test_case_meshed_pumps(use_numba, log_results=False): :rtype: """ net = nw.gas_meshed_pumps() - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 15 if use_numba else 15 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, calc_compression_power=False) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -125,7 +142,11 @@ def test_case_meshed_pumps(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_n(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-3) assert np.all(v_diff_abs < 1e-3) @@ -134,7 +155,10 @@ def test_case_meshed_2valves_n(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.gas_meshed_two_valves(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-3) @@ -152,7 +176,10 @@ def test_case_one_pipe1_n(use_numba, log_results=False): :rtype: """ net = nw.gas_one_pipe1(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -168,7 +195,10 @@ def test_case_one_pipe1_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_one_pipe1(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -185,7 +215,10 @@ def test_case_one_pipe2_n(use_numba, log_results=False): :rtype: """ net = nw.gas_one_pipe2(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 4 if use_numba else 4 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -201,7 +234,10 @@ def test_case_one_pipe2_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_one_pipe2(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -219,7 +255,10 @@ def test_case_strand_2pipes_n(use_numba, log_results=False): :rtype: """ net = nw.gas_strand_2pipes(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -235,7 +274,10 @@ def test_case_strand_2pipes_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_strand_2pipes(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -251,7 +293,10 @@ def test_case_strand_pump(use_numba, log_results=False): :rtype: """ net = nw.gas_strand_pump() - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 4 if use_numba else 4 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, calc_compression_power=False) assert np.all(p_diff < 1e-2) assert np.all(v_diff_abs < 3e-2) @@ -269,7 +314,10 @@ def test_case_tcross1_n(use_numba, log_results=False): :rtype: """ net = nw.gas_tcross1(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -285,7 +333,10 @@ def test_case_tcross1_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_tcross1(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -302,7 +353,10 @@ def test_case_tcross2_n(use_numba, log_results=False): :rtype: """ net = nw.gas_tcross2(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -318,7 +372,10 @@ def test_case_tcross2_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_tcross2(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -336,7 +393,10 @@ def test_case_2eg_hnet_n(use_numba, log_results=False): :rtype: """ net = nw.gas_2eg_hnet(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) @@ -352,7 +412,10 @@ def test_case_2eg_hnet_pc(use_numba, log_results=False): :rtype: """ net = nw.gas_2eg_hnet(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, friction_model="colebrook", + max_iter_hyd = 5 if use_numba else 5 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + friction_model="colebrook", use_numba=use_numba) assert np.all(p_diff < 1e-4) assert np.all(v_diff_abs < 1e-2) diff --git a/src/pandapipes/test/stanet_comparison/test_water_stanet.py b/src/pandapipes/test/stanet_comparison/test_water_stanet.py index cb64b20a9..8077cedf3 100644 --- a/src/pandapipes/test/stanet_comparison/test_water_stanet.py +++ b/src/pandapipes/test/stanet_comparison/test_water_stanet.py @@ -3,8 +3,9 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import numpy as np -import pandapipes.networks.simple_water_networks as nw import pytest + +import pandapipes.networks.simple_water_networks as nw from pandapipes.pipeflow import logger as pf_logger from pandapipes.test.stanet_comparison.pipeflow_stanet_comparison import pipeflow_stanet_comparison @@ -30,7 +31,11 @@ def test_case_district_grid_n(use_numba, log_results=False): :rtype: """ net = nw.water_district_grid(method="n") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 7 if use_numba else 7 + p_diff, v_diff_abs = pipeflow_stanet_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -46,8 +51,12 @@ def test_case_district_grid_pc(use_numba, log_results=False): :rtype: """ net = nw.water_district_grid(method="pc") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, - friction_model="colebrook") + max_iter_hyd = 11 if use_numba else 11 + p_diff, v_diff_abs = pipeflow_stanet_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, + friction_model="colebrook") assert np.all(p_diff < 3e-2) assert np.all(v_diff_abs < 3e-2) @@ -64,7 +73,10 @@ def test_case_pumps_n(use_numba, log_results=False): :rtype: """ net = nw.water_meshed_pumps(results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 20 if use_numba else 20 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -80,7 +92,11 @@ def test_case_delta_n(use_numba, log_results=False): :rtype: """ net = nw.water_meshed_delta(results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 25 if use_numba else 25 + p_diff, v_diff_abs = pipeflow_stanet_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -89,7 +105,10 @@ def test_case_delta_n(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_n(use_numba, log_results=False): net = nw.water_meshed_2valves(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 1e-3) assert np.all(v_diff_abs < 1e-3) @@ -98,7 +117,10 @@ def test_case_meshed_2valves_n(use_numba, log_results=False): @pytest.mark.parametrize("use_numba", [True, False]) def test_case_meshed_2valves_pc(use_numba, log_results=False): net = nw.water_meshed_2valves(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 1e-3) assert np.all(v_diff_abs < 1e-3) @@ -116,7 +138,10 @@ def test_case_one_pipe1_n(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe1(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -132,7 +157,10 @@ def test_case_one_pipe1_pc(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe1(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -149,7 +177,10 @@ def test_case_one_pipe2_n(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe2(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -165,7 +196,10 @@ def test_case_one_pipe2_pc(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe2(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -182,7 +216,10 @@ def test_case_one_pipe3_n(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe3(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -198,7 +235,10 @@ def test_case_one_pipe3_pc(use_numba, log_results=False): :rtype: """ net = nw.water_one_pipe3(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -216,7 +256,10 @@ def test_case_simple_strand_net_n(use_numba, log_results=False): :rtype: """ net = nw.water_simple_strand_net(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -232,7 +275,10 @@ def test_case_simple_strand_net_pc(use_numba, log_results=False): :rtype: """ net = nw.water_simple_strand_net(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 1e-2) assert np.all(v_diff_abs < 3e-2) @@ -249,7 +295,10 @@ def test_case_two_pipes_n(use_numba, log_results=False): :rtype: """ net = nw.water_strand_2pipes(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -265,7 +314,10 @@ def test_case_two_pipes_pc(use_numba, log_results=False): :rtype: """ net = nw.water_strand_2pipes(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -282,8 +334,12 @@ def test_case_cross_pc(use_numba, log_results=False): :rtype: """ net = nw.water_strand_cross(results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, - friction_model="colebrook") + max_iter_hyd = 18 if use_numba else 18 + p_diff, v_diff_abs = pipeflow_stanet_comparison( + net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, + friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -299,7 +355,10 @@ def test_case_pump_n(use_numba, log_results=False): :rtype: """ net = nw.water_strand_pump() - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -316,7 +375,10 @@ def test_case_tcross_n(use_numba, log_results=False): :rtype: """ net = nw.water_tcross(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -332,7 +394,10 @@ def test_case_tcross_pc(use_numba, log_results=False): :rtype: """ net = nw.water_tcross(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 3 if use_numba else 3 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -350,7 +415,10 @@ def test_case_2eg_two_pipes_n(use_numba, log_results=False): :rtype: """ net = nw.water_2eg_two_pipes(method="n", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba) + max_iter_hyd = 6 if use_numba else 6 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba) assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) @@ -366,7 +434,10 @@ def test_case_2eg_two_pipes_pc(use_numba, log_results=False): :rtype: """ net = nw.water_2eg_two_pipes(method="pc", results_from="stanet") - p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, use_numba=use_numba, + max_iter_hyd = 16 if use_numba else 16 + p_diff, v_diff_abs = pipeflow_stanet_comparison(net, log_results, + max_iter_hyd=max_iter_hyd, + use_numba=use_numba, friction_model="colebrook") assert np.all(p_diff < 2e-3) assert np.all(v_diff_abs < 3e-2) diff --git a/src/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py index eedd94033..9d8193e49 100644 --- a/src/pandapipes/test/test_toolbox.py +++ b/src/pandapipes/test/test_toolbox.py @@ -257,7 +257,8 @@ def test_select_subnet(base_net_is_wo_pumps): # check length of results net = nw.gas_tcross2() - pandapipes.pipeflow(net) + max_iter_hyd = 2 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) net2 = pandapipes.select_subnet(net, net.junction.index[:-3], include_results=True) for comp in net.component_list: assert len(net2["res_" + comp.table_name()]) == len(net2[comp.table_name()]) @@ -274,7 +275,8 @@ def test_pit_extraction(): for name in names: filename = os.path.join(folder, "example_%s%s.json" % (max_ver, name)) net = pandapipes.from_json(filename) - pandapipes.pipeflow(net) + max_iter_hyd = 10 if '_water' in name else 5 + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd) node_table, branch_table = pandapipes.get_internal_tables_pandas(net) From 36058440b51300ad60828fa93c71d9db5820fa89 Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:50:45 +0100 Subject: [PATCH 118/237] - consider the max iter number correctly --- src/pandapipes/pipeflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 0a341282b..6cffa00f4 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -128,7 +128,7 @@ def hydraulics(net): error_m, error_p, residual_norm = [], [], None # This loop is left as soon as the solver converged - while not net.converged and niter <= max_iter: + while not net.converged and niter < max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place @@ -173,7 +173,7 @@ def heat_transfer(net): niter = 0 # This loop is left as soon as the solver converged - while not net.converged and niter <= max_iter: + while not net.converged and niter < max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place From 5e0b8f4adb395bfc39ada5bc25ce5cc6064118c8 Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:52:07 +0100 Subject: [PATCH 119/237] max_iter_hydr in stanet comparison instead of iter --- .../test/stanet_comparison/pipeflow_stanet_comparison.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py index 56583d25d..9c7725c2d 100644 --- a/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py +++ b/src/pandapipes/test/stanet_comparison/pipeflow_stanet_comparison.py @@ -16,7 +16,8 @@ def pipeflow_stanet_comparison(net, log_results=True, friction_model='nikuradse', - only_update_hydraulic_matrix=False, **kwargs): + only_update_hydraulic_matrix=False, + max_iter_hyd=10, **kwargs): """ :param net: @@ -32,7 +33,7 @@ def pipeflow_stanet_comparison(net, log_results=True, friction_model='nikuradse' :return: :rtype: """ - pandapipes.pipeflow(net, mode='hydraulics', stop_condition="tol", iter=100, tol_p=1e-7, + pandapipes.pipeflow(net, mode='hydraulics', stop_condition="tol",max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model=friction_model, only_update_hydraulic_matrix=only_update_hydraulic_matrix, **kwargs) @@ -128,7 +129,7 @@ def retrieve_velocity_gas(net, element='pipe'): :rtype: """ if 'v_stanet' not in net[element]: - net[element]['v_stanet'] = [] + net[element].insert(len(net[element].columns), 'v_stanet', np.nan) v_stanet = net[element].v_stanet v_valid = pd.notnull(v_stanet) v_stanet = v_stanet.loc[v_valid] From 4988eb033a4398eb4ad08e6092a2c973c9819740 Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:53:05 +0100 Subject: [PATCH 120/237] type np.int32 instead of int --- src/pandapipes/properties/properties_toolbox.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index c7e7c9e73..99a616d05 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -149,12 +149,13 @@ def calculate_mass_fraction_from_molar_fraction(component_molar_proportions, com def get_branch_density(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE].astype(int) + # todo consider flow change in case of heat calculation (relevant for bidirectional calculation) + from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] if fluid.is_gas: from_p = node_pit[from_nodes, PINIT] + node_pit[from_nodes, PAMB] - to_nodes = branch_pit[:, TO_NODE].astype(int) + to_nodes = branch_pit[:, TO_NODE].astype(np.int32) to_p = node_pit[to_nodes, PINIT] + node_pit[to_nodes, PAMB] normal_rho = fluid.get_density(NORMAL_TEMPERATURE) from_rho = np.divide(normal_rho * NORMAL_TEMPERATURE * from_p, @@ -168,7 +169,7 @@ def get_branch_density(net, fluid, node_pit, branch_pit): return rho def get_branch_eta(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE].astype(int) + from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 @@ -176,7 +177,7 @@ def get_branch_eta(net, fluid, node_pit, branch_pit): return eta def get_branch_cp(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE].astype(int) + from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 From 09d12ba4fc9b9c71792030d638ecce1876fc2bca Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:53:27 +0100 Subject: [PATCH 121/237] take correct density in norm volume --- src/pandapipes/pf/result_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 93f9cf318..91e198569 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -61,7 +61,7 @@ def get_basic_branch_results(net, branch_pit, node_pit): fluid = get_fluid(net) t0 = node_pit[from_nodes, TINIT_NODE] t1 = node_pit[to_nodes, TINIT_NODE] - vf = branch_pit[:, MDOTINIT] / get_branch_density(net,fluid, node_pit, branch_pit) + vf = branch_pit[:, MDOTINIT] / get_fluid(net).get_density(NORMAL_TEMPERATURE) v = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ From 0c60e92efe2677110d380391f1071cc48b72911a Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 27 Mar 2024 15:55:03 +0100 Subject: [PATCH 122/237] replace iter by max_iter_hyd --- src/pandapipes/test/pipeflow_internals/test_inservice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 3dd27f2fc..01d58a7ce 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -654,15 +654,15 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): net = create_net_wo_ext_grid ex1 = pandapipes.create_ext_grid(net, junction=3, t_k=300) ex2 = pandapipes.create_ext_grid(net, junction=3, p_bar=1) + max_iter_hyd = 9 if use_numba else 9 with pytest.raises(PipeflowNotConverged): net.ext_grid.at[ex2, 'in_service'] = False - pandapipes.pipeflow(net, iter=100, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", + pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged net.ext_grid.at[ex1, 'in_service'] = False net.ext_grid.at[ex2, 'in_service'] = True - max_iter_hyd = 9 if use_numba else 9 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert not np.all(np.isnan(net.res_junction.p_bar.values)) From f92fe68fcdbdc9932ca46d51f4da754fea1dcc16 Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 3 Apr 2024 07:52:12 +0200 Subject: [PATCH 123/237] correct derivations in the derivative toolbox, consideration of the negative derivation in build_system_matrix.py --- src/pandapipes/pf/build_system_matrix.py | 9 ++++----- src/pandapipes/pf/derivative_toolbox.py | 14 +++++++------- src/pandapipes/pf/derivative_toolbox_numba.py | 14 +++++++------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index 51a17c717..98e926690 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -67,16 +67,15 @@ def build_system_matrix(net, branch_pit, node_pit, heat_mode): if not heat_mode: # pdF_dv - system_data[:len_b] = branch_pit[:, JAC_DERIV_DM] + system_data[:len_b] = branch_pit[:, JAC_DERIV_DM] * (-1) # pdF_dpi - system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DP] + system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DP] * (-1) # pdF_dpi1 - system_data[2 * len_b:3 * len_b] = branch_pit[:, JAC_DERIV_DP1] + system_data[2 * len_b:3 * len_b] = branch_pit[:, JAC_DERIV_DP1] * (-1) # jdF_dv_from_nodes system_data[3 * len_b:len_fn1] = branch_pit[not_slack_fn_branch_mask, JAC_DERIV_DM_NODE] # jdF_dv_to_nodes - system_data[len_fn1:len_tn1] = branch_pit[not_slack_tn_branch_mask, - JAC_DERIV_DM_NODE] * (-1) + system_data[len_fn1:len_tn1] = branch_pit[not_slack_tn_branch_mask, JAC_DERIV_DM_NODE] * (-1) # pc_nodes and p_nodes system_data[len_tn1:] = 1 else: diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index fa60302a5..1f0ec4fad 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -21,16 +21,16 @@ def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init friction_term = np.divide(branch_pit[:, LENGTH] * branch_pit[:, LAMBDA], branch_pit[:, D]) + branch_pit[:, LC] const_term = np.divide(1, branch_pit[:, AREA] ** 2 * rho_n * P_CONVERSION * 2) - df_dm = const_term * (2 * m_init_abs * friction_term + der_lambda + df_dm = - const_term * (2 * m_init_abs * friction_term + der_lambda * np.divide(branch_pit[:, LENGTH], branch_pit[:, D]) * m_init2) load_vec = p_diff + branch_pit[:, PL] + const_height - const_term * m_init2 * friction_term - df_dp = np.ones_like(der_lambda) * (-1) - df_dp1 = np.ones_like(der_lambda) + df_dp = np.ones_like(der_lambda) + df_dp1 = np.ones_like(der_lambda) * (-1) df_dm_nodes = np.ones_like(der_lambda) - + load_vec_nodes = branch_pit[:, MDOTINIT] return load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 @@ -51,11 +51,11 @@ def derivatives_hydraulic_comp_np(node_pit, branch_pit, lambda_, der_lambda, p_i normal_term = np.divide(NORMAL_PRESSURE, NORMAL_TEMPERATURE * P_CONVERSION * rho_n * branch_pit[:, AREA] ** 2) const_term_p = normal_term * m_init2 * friction_term * tm - df_dp = -1. + const_term_p * p_sum_div * (der_comp - comp_fact * p_sum_div) - df_dp1 = 1. + const_term_p * p_sum_div * (der_comp1 - comp_fact * p_sum_div) + df_dp = 1. - const_term_p * p_sum_div * (der_comp - comp_fact * p_sum_div) + df_dp1 = -1. - const_term_p * p_sum_div * (der_comp1 - comp_fact * p_sum_div) const_term_m = normal_term * p_sum_div * tm * comp_fact - df_dm = const_term_m * (2 * m_init_abs * friction_term + + df_dm = - const_term_m * (2 * m_init_abs * friction_term + np.divide(der_lambda * branch_pit[:, LENGTH] * m_init2, branch_pit[:, D])) load_vec = p_diff + branch_pit[:, PL] + const_height \ diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 98de35aad..0f40d69fd 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -21,8 +21,8 @@ def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_i le = der_lambda.shape[0] load_vec = np.zeros_like(der_lambda) df_dm = np.zeros_like(der_lambda) - df_dp = np.ones_like(der_lambda) * (-1) - df_dp1 = np.ones_like(der_lambda) + df_dp = np.ones_like(der_lambda) + df_dp1 = np.ones_like(der_lambda) * (-1) load_vec_nodes = np.zeros_like(der_lambda) df_dm_nodes = np.ones_like(der_lambda) @@ -35,7 +35,7 @@ def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_i + branch_pit[i][LC] const_term = np.divide(1, branch_pit[i][AREA] ** 2 * rho_n[i] * P_CONVERSION * 2) - df_dm[i] = const_term * (2 * m_init_abs * friction_term + der_lambda[i] + df_dm[i] = -1. * const_term * (2 * m_init_abs * friction_term + der_lambda[i] * np.divide(branch_pit[i][LENGTH], branch_pit[i][D]) * m_init2) load_vec[i] = p_diff + branch_pit[i][PL] + const_height - const_term * m_init2 * friction_term @@ -52,7 +52,7 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, load_vec = np.zeros_like(lambda_) df_dm = np.zeros_like(lambda_) df_dp = np.zeros_like(lambda_) - df_dp1 = np.zeros_like(lambda_) * (-1) + df_dp1 = np.zeros_like(lambda_) load_vec_nodes = np.zeros_like(der_lambda) df_dm_nodes = np.ones_like(der_lambda) from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) @@ -80,10 +80,10 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, - normal_term * comp_fact[i] * m_init2 * friction_term * p_sum_div * tm const_term = normal_term * m_init2 * friction_term * tm - df_dp[i] = -1. + const_term * p_sum_div * (der_comp[i] - comp_fact[i] * p_sum_div) - df_dp1[i] = 1. + const_term * p_sum_div * (der_comp1[i] - comp_fact[i] * p_sum_div) + df_dp[i] = 1. - const_term * p_sum_div * (der_comp[i] - comp_fact[i] * p_sum_div) + df_dp1[i] = -1. - const_term * p_sum_div * (der_comp1[i] - comp_fact[i] * p_sum_div) - df_dm[i] = normal_term * comp_fact[i] * p_sum_div * tm * (2 * m_init_abs * friction_term \ + df_dm[i] = -1. * normal_term * comp_fact[i] * p_sum_div * tm * (2 * m_init_abs * friction_term \ + np.divide(der_lambda[i] * branch_pit[i][LENGTH] * m_init2, branch_pit[i][D])) load_vec_nodes[i] = branch_pit[i][MDOTINIT] From 35c56e041c0eb1acb646238a92c4bfa554d6398d Mon Sep 17 00:00:00 2001 From: SRDM Date: Wed, 3 Apr 2024 07:52:21 +0200 Subject: [PATCH 124/237] bugfix --- src/pandapipes/converter/stanet/preparing_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index ae8c9faeb..f3edbcb94 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -201,7 +201,7 @@ def get_net_params(net, stored_data): else: pandapipes.set_user_pf_options( net, friction_model=known_friction_models[net_params["friction_model"]], - max_iter_hyd=net_params["max_iterations"], max_iter_therm=net_params["max_iteration"] + max_iter_hyd=net_params["max_iterations"], max_iter_therm=net_params["max_iterations"] ) if net_params["compress_model"] != "linear": logger.warning("The compressibility model %s is not implemented in pandapipes, which might " From 77c83e56b3af173a00eac24d2906fdc7713ab3ec Mon Sep 17 00:00:00 2001 From: SRDM Date: Thu, 4 Apr 2024 16:29:30 +0200 Subject: [PATCH 125/237] - removed todo - remove unnecessary np.abs --- src/pandapipes/pf/derivative_calculation.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 227dd6074..5c45a75b8 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -196,7 +196,6 @@ def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area): :rtype: """ - # TODO: check if some formulas with constants can be shortened b_term = np.zeros_like(m) df_dm = np.zeros_like(m) df_dlambda = np.zeros_like(m) @@ -217,13 +216,12 @@ def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area): return lambda_der elif friction_model == "swamee-jain": - param = (k[pos] / (3.7 * d[pos]) + 5.74 * (np.abs(eta[pos] * area[pos])) ** 0.9 / - ((np.abs(m[pos] * d[pos])) ** 0.9)) + param = (k[pos] / (3.7 * d[pos]) + 5.74 * ((eta[pos] * area[pos]) / + (np.abs(m[pos]) * d[pos])) ** 0.9) # 0.5 / (log(10) * log(param)^3 * param) * 5.166 * abs(eta)^0.9 / (abs(rho * d)^0.9 # * abs(v_corr)^1.9) lambda_der[pos] = 0.5 * np.log(10) ** 2 / (np.log(param) ** 3) / param * 5.166 \ - * np.abs(eta[pos] * area[pos]) ** 0.9 / ((np.abs(d[pos]) ** 0.9) - * np.abs(m[pos]) ** 1.9) + * ((eta[pos] * area[pos]) / (d[pos])) ** 0.9 * np.abs(m[pos]) ** -1.9 return lambda_der else: lambda_der[pos] = -(64 * eta[pos] * area[pos]) / (m[pos] ** 2 * d[pos]) From dc106eba0081affa5b0af0b3d21977c27df171d3 Mon Sep 17 00:00:00 2001 From: SRDM Date: Thu, 4 Apr 2024 16:59:43 +0200 Subject: [PATCH 126/237] - remove todo as obsolete --- src/pandapipes/pf/derivative_toolbox.py | 2 +- src/pandapipes/pf/derivative_toolbox_numba.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index 1f0ec4fad..394078198 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -108,7 +108,7 @@ def calc_medium_pressure_with_derivative_np(p_init_i_abs, p_init_i1_abs): return p_m, der_p_m, der_p_m1 -# TODO: check NR colebrook + def colebrook_np(re, d, k, lambda_nikuradse, dummy, max_iter): """ diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 0f40d69fd..5cadb5524 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -136,7 +136,7 @@ def calc_medium_pressure_with_derivative_numba(p_init_i_abs, p_init_i1_abs): + 2 * p_init_i1_abs[i] * diff_p_cub) * diff_p_sq_div ** 2 * val return p_m, der_p_m, der_p_m1 -# TODO: check NR colebrook + @jit((float64[:], float64[:], float64[:], float64[:], float64[:], int64), nopython=True) def colebrook_numba(re, d, k, lambda_nikuradse, dummy, max_iter): lambda_cb = lambda_nikuradse.copy() From f0154179de2de5b07d7b5f66b1868cf166e9cd45 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Thu, 4 Apr 2024 17:17:09 +0200 Subject: [PATCH 127/237] shift some node entries from pipe component to branch_w_internals_models.py --- .../branch_w_internals_models.py | 17 +++++++- .../component_models/pipe_component.py | 43 +++---------------- 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py index c21d7d582..c1bbcbd4a 100644 --- a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py @@ -5,9 +5,11 @@ import numpy as np from pandapipes.component_models.abstract_models.branch_models import BranchComponent -from pandapipes.component_models.component_toolbox import set_entry_check_repeat +from pandapipes.component_models.component_toolbox import set_entry_check_repeat, vinterp, \ + p_correction_height_air from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, RHO, ETA, CP, ELEMENT_IDX, TOUTINIT -from pandapipes.idx_node import L, node_cols, TINIT as TINIT_NODE +from pandapipes.idx_node import (L, node_cols, TINIT as TINIT_NODE, HEIGHT, PINIT, PAMB, + ACTIVE as ACTIVE_ND) from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number from pandapipes.properties.fluids import get_fluid @@ -158,6 +160,17 @@ def create_pit_node_entries(cls, net, node_pit): junction_indices = get_lookup(net, "node", "index")[junction_table_name] fj_nodes = junction_indices[from_junctions] tj_nodes = junction_indices[to_junctions] + + int_node_pit[:, HEIGHT] = vinterp(junction_pit[fj_nodes, HEIGHT], + junction_pit[tj_nodes, HEIGHT], int_node_number) + int_node_pit[:, PINIT] = vinterp(junction_pit[fj_nodes, PINIT], + junction_pit[tj_nodes, PINIT], int_node_number) + int_node_pit[:, TINIT_NODE] = vinterp(junction_pit[fj_nodes, TINIT_NODE], + junction_pit[tj_nodes, TINIT_NODE], + int_node_number) + int_node_pit[:, PAMB] = p_correction_height_air(int_node_pit[:, HEIGHT]) + int_node_pit[:, ACTIVE_ND] = \ + np.repeat(net[cls.table_name()][cls.active_identifier()].values, int_node_number) return table_nr, int_node_number, int_node_pit, junction_pit, fj_nodes, tj_nodes @classmethod diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 550eb1ff1..5c6b5fbd2 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -5,18 +5,17 @@ import matplotlib.pyplot as plt import numpy as np from numpy import dtype + from pandapipes.component_models.abstract_models import BranchWInternalsComponent -from pandapipes.component_models.component_toolbox import p_correction_height_air, \ - vinterp, set_entry_check_repeat +from pandapipes.component_models.component_toolbox import set_entry_check_repeat from pandapipes.component_models.junction_component import Junction from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE -from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \ - VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC -from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, \ - RHO as RHO_NODES, PAMB, ACTIVE as ACTIVE_ND +from pandapipes.idx_branch import (FROM_NODE, TO_NODE, LENGTH, D, AREA, K, VINIT, + ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC) +from pandapipes.idx_node import PINIT, TINIT as TINIT_NODE, PAMB from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup -from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \ - extract_branch_results_without_internals +from pandapipes.pf.result_extraction import (extract_branch_results_with_internals, + extract_branch_results_without_internals) try: import pandaplan.core.pplog as logging @@ -91,34 +90,6 @@ def create_node_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current return end, current_table - @classmethod - def create_pit_node_entries(cls, net, node_pit): - """ - Function which creates pit node entries. - - :param net: The pandapipes network - :type net: pandapipesNet - :param node_pit: - :type node_pit: - :return: No Output. - """ - table_nr, int_node_number, int_node_pit, junction_pit, fj_nodes, tj_nodes = \ - super().create_pit_node_entries(net, node_pit) - if table_nr is None: - return - get_lookup(net, "node", "index") - int_node_pit[:, HEIGHT] = vinterp(junction_pit[fj_nodes, HEIGHT], - junction_pit[tj_nodes, HEIGHT], int_node_number) - int_node_pit[:, PINIT] = vinterp(junction_pit[fj_nodes, PINIT], - junction_pit[tj_nodes, PINIT], int_node_number) - int_node_pit[:, TINIT_NODE] = vinterp(junction_pit[fj_nodes, TINIT_NODE], - junction_pit[tj_nodes, TINIT_NODE], - int_node_number) - int_node_pit[:, PAMB] = p_correction_height_air(int_node_pit[:, HEIGHT]) - int_node_pit[:, RHO_NODES] = get_fluid(net).get_density(int_node_pit[:, TINIT_NODE]) - int_node_pit[:, ACTIVE_ND] = \ - np.repeat(net[cls.table_name()][cls.active_identifier()].values, int_node_number) - @classmethod def create_pit_branch_entries(cls, net, branch_pit): """ From 2968c2583f4bb90c3685470ca5c0ba64c0c9d1f1 Mon Sep 17 00:00:00 2001 From: SRDM Date: Mon, 8 Apr 2024 12:25:20 +0200 Subject: [PATCH 128/237] use FROM_NODE_T and TO_NODE_T for density, eta and cp calculation during the pipeflow (especially relevant for the bidirectional pipeflow) --- .../abstract_models/branch_w_internals_models.py | 4 +++- .../abstract_models/branch_wo_internals_models.py | 4 +++- src/pandapipes/pf/derivative_calculation.py | 6 +++--- src/pandapipes/pf/pipeflow_setup.py | 4 +++- src/pandapipes/pf/result_extraction.py | 11 +++++------ src/pandapipes/properties/properties_toolbox.py | 13 ++++++------- .../test/pipeflow_internals/test_inservice.py | 4 ++-- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py index a50466352..2e0a523e1 100644 --- a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py @@ -6,7 +6,7 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent from pandapipes.component_models.component_toolbox import set_entry_check_repeat -from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX +from pandapipes.idx_branch import ACTIVE, FROM_NODE, FROM_NODE_T, TO_NODE, TO_NODE_T, TOUTINIT, ELEMENT_IDX from pandapipes.idx_node import L, node_cols, TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number @@ -194,7 +194,9 @@ def create_pit_branch_entries(cls, net, branch_pit): branch_w_internals_pit, ACTIVE, net[cls.table_name()][cls.active_identifier()].values, internal_pipe_number, has_internals) branch_w_internals_pit[:, FROM_NODE] = from_nodes + branch_w_internals_pit[:, FROM_NODE_T] = from_nodes branch_w_internals_pit[:, TO_NODE] = to_nodes + branch_w_internals_pit[:, TO_NODE_T] = to_nodes branch_w_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] return branch_w_internals_pit, internal_pipe_number diff --git a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py index 9af9e0df3..0ce5f8e57 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py @@ -4,7 +4,7 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent -from pandapipes.idx_branch import FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX, ACTIVE +from pandapipes.idx_branch import FROM_NODE, FROM_NODE_T, TO_NODE, TO_NODE_T, TOUTINIT, ELEMENT_IDX, ACTIVE from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup @@ -80,7 +80,9 @@ def create_pit_branch_entries(cls, net, branch_pit): = super().create_pit_branch_entries(net, branch_pit) branch_wo_internals_pit[:, ELEMENT_IDX] = net[cls.table_name()].index.values branch_wo_internals_pit[:, FROM_NODE] = from_nodes + branch_wo_internals_pit[:, FROM_NODE_T] = from_nodes branch_wo_internals_pit[:, TO_NODE] = to_nodes + branch_wo_internals_pit[:, TO_NODE_T] = to_nodes branch_wo_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values return branch_wo_internals_pit diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 5c45a75b8..e4ec18cd8 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -7,7 +7,7 @@ from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.properties.fluids import get_fluid from pandapipes.constants import NORMAL_TEMPERATURE -from pandapipes.properties.properties_toolbox import get_branch_density, get_branch_eta, get_branch_cp +from pandapipes.properties.properties_toolbox import get_branch_real_density, get_branch_real_eta, get_branch_cp def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): @@ -27,8 +27,8 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): fluid = get_fluid(net) gas_mode = fluid.is_gas friction_model = options["friction_model"] - rho = get_branch_density(net, fluid, node_pit, branch_pit) - eta = get_branch_eta(net, fluid, node_pit, branch_pit) + rho = get_branch_real_density(fluid, node_pit, branch_pit) + eta = get_branch_real_eta(fluid, node_pit, branch_pit) rho_n = fluid.get_density([NORMAL_TEMPERATURE] * len(branch_pit)) lambda_, re = calc_lambda( diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index a91a989db..b94f99de4 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -10,7 +10,7 @@ from scipy.sparse import coo_matrix, csgraph from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ - ACTIVE as ACTIVE_BR, MDOTINIT + ACTIVE as ACTIVE_BR, MDOTINIT, FROM_NODE_T, TO_NODE_T from pandapipes.idx_node import NODE_TYPE, P, NODE_TYPE_T, node_cols, T, ACTIVE as ACTIVE_ND, \ TABLE_IDX as TABLE_IDX_ND, ELEMENT_IDX as ELEMENT_IDX_ND from pandapipes.pf.internals_toolbox import _sum_by_group @@ -706,8 +706,10 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): if reduced_node_lookup is not None: active_pit["branch"][:, FROM_NODE] = reduced_node_lookup[ branch_pit[branches_connected, FROM_NODE].astype(np.int32)] + active_pit["branch"][:, FROM_NODE_T] = active_pit["branch"][:, FROM_NODE] active_pit["branch"][:, TO_NODE] = reduced_node_lookup[ branch_pit[branches_connected, TO_NODE].astype(np.int32)] + active_pit["branch"][:, TO_NODE_T] = active_pit["branch"][:, TO_NODE] net["_active_pit"] = active_pit for el, connected_els in els.items(): diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 91e198569..5e277608f 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -7,7 +7,6 @@ from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option from pandapipes.properties.fluids import get_fluid -from pandapipes.properties.properties_toolbox import get_branch_density try: from numba import jit @@ -39,11 +38,11 @@ def extract_all_results(net, calculation_mode): if get_net_option(net, "use_numba"): v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ normfactor_to, normfactor_mean = get_branch_results_gas_numba( - net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) + net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) else: v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ normfactor_to, normfactor_mean = get_branch_results_gas( - net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) + net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) gas_branch_results = { "v_gas_from": v_gas_from, "v_gas_to": v_gas_to, "v_gas_mean": v_gas_mean, "p_from": p_from, "p_to": p_to, "p_abs_from": p_abs_from, "p_abs_to": p_abs_to, @@ -75,7 +74,7 @@ def get_branch_results_gas(net, branch_pit, node_pit, from_nodes, to_nodes, v_mp p_abs_mean = np.empty_like(p_abs_to) p_abs_mean[~mask] = p_abs_from[~mask] p_abs_mean[mask] = 2 / 3 * (p_abs_from[mask] ** 3 - p_abs_to[mask] ** 3) \ - / (p_abs_from[mask] ** 2 - p_abs_to[mask] ** 2) + / (p_abs_from[mask] ** 2 - p_abs_to[mask] ** 2) fluid = get_fluid(net) t_from = node_pit[from_nodes, TINIT_NODE] @@ -93,7 +92,7 @@ def get_branch_results_gas(net, branch_pit, node_pit, from_nodes, to_nodes, v_mp v_gas_to = v_mps * normfactor_to v_gas_mean = v_mps * normfactor_mean - return v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from,\ + return v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ normfactor_to, normfactor_mean @@ -264,7 +263,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul branch_results[entry][f:t][comp_connected_ht] -def extract_results_active_pit(net, mode="hydraulics"): +def extract_results_active_pit(net, mode="hydraulics"): """ Extract the pipeflow results from the internal pit structure ("_active_pit") to the general pit structure. diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index 99a616d05..2d2175a24 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -5,7 +5,7 @@ import numpy as np from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE -from pandapipes.idx_branch import TOUTINIT, FROM_NODE, TO_NODE +from pandapipes.idx_branch import TOUTINIT, FROM_NODE_T, TO_NODE from pandapipes.idx_node import TINIT, PINIT, PAMB @@ -148,9 +148,8 @@ def calculate_mass_fraction_from_molar_fraction(component_molar_proportions, com return com_array[:, 3] -def get_branch_density(net, fluid, node_pit, branch_pit): - # todo consider flow change in case of heat calculation (relevant for bidirectional calculation) - from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) +def get_branch_real_density(fluid, node_pit, branch_pit): + from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] if fluid.is_gas: @@ -168,8 +167,8 @@ def get_branch_density(net, fluid, node_pit, branch_pit): rho = (from_rho + to_rho) / 2 return rho -def get_branch_eta(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) +def get_branch_real_eta(fluid, node_pit, branch_pit): + from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 @@ -177,7 +176,7 @@ def get_branch_eta(net, fluid, node_pit, branch_pit): return eta def get_branch_cp(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) + from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 01d58a7ce..29ba322fe 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -344,7 +344,7 @@ def test_connectivity_heat2(complex_heat_connectivity_grid, use_numba): net.pipe.at[7, "in_service"] = True max_iter_hyd = 3 if use_numba else 3 - max_iter_therm = 4 if use_numba else 4 + max_iter_therm = 5 if use_numba else 5 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, mode="all", check_connectivity=True, use_numba=use_numba) @@ -413,7 +413,7 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): net2 = copy.deepcopy(net) max_iter_hyd = 9 if use_numba else 9 - max_iter_therm = 5 if use_numba else 5 + max_iter_therm = 6 if use_numba else 6 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, mode="all", check_connectivity=True, use_numba=use_numba) pandapipes.pipeflow(net2, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, From 22f80a053c9da00e07eeebc5abb402196ea47064 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 10:45:05 +0200 Subject: [PATCH 129/237] considering - for delta x and not in build_system_matrix.py in regards to NR --- src/pandapipes/pf/build_system_matrix.py | 10 +++++----- src/pandapipes/pipeflow.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index 100f0292d..1ca2b272c 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -67,15 +67,15 @@ def build_system_matrix(net, branch_pit, node_pit, heat_mode): if not heat_mode: # pdF_dv - system_data[:len_b] = branch_pit[:, JAC_DERIV_DM] * (-1) + system_data[:len_b] = branch_pit[:, JAC_DERIV_DM] # pdF_dpi - system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DP] * (-1) + system_data[len_b:2 * len_b] = branch_pit[:, JAC_DERIV_DP] # pdF_dpi1 - system_data[2 * len_b:3 * len_b] = branch_pit[:, JAC_DERIV_DP1] * (-1) + system_data[2 * len_b:3 * len_b] = branch_pit[:, JAC_DERIV_DP1] # jdF_dv_from_nodes - system_data[3 * len_b:len_fn1] = branch_pit[not_slack_fn_branch_mask, JAC_DERIV_DM_NODE] + system_data[3 * len_b:len_fn1] = branch_pit[not_slack_fn_branch_mask, JAC_DERIV_DM_NODE] * (-1) # jdF_dv_to_nodes - system_data[len_fn1:len_tn1] = branch_pit[not_slack_tn_branch_mask, JAC_DERIV_DM_NODE] * (-1) + system_data[len_fn1:len_tn1] = branch_pit[not_slack_tn_branch_mask, JAC_DERIV_DM_NODE] # pc_nodes and p_nodes system_data[len_tn1:] = 1 else: diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 6cffa00f4..629c1cd0f 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -229,8 +229,8 @@ def solve_hydraulics(net): p_init_old = node_pit[:, PINIT].copy() x = spsolve(jacobian, epsilon) - branch_pit[:, MDOTINIT] += x[len(node_pit):] - node_pit[:, PINIT] += x[:len(node_pit)] * options["alpha"] + branch_pit[:, MDOTINIT] -= x[len(node_pit):] + node_pit[:, PINIT] -= x[:len(node_pit)] * options["alpha"] return branch_pit[:, MDOTINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon From 66d41dec7becd9f22dc41352b02d550dd20e20f6 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 9 Apr 2024 12:46:24 +0200 Subject: [PATCH 130/237] corrections in heat consumer creation: - shifted some branch initialization to branch_wzerolength_models.py (also for heat_exchanger_component.py) - switched order of arguments in component (qext and mdot) --- .../abstract_models/branch_wzerolength_models.py | 4 +++- .../component_models/heat_consumer_component.py | 10 ++++------ .../component_models/heat_exchanger_component.py | 5 +---- src/pandapipes/create.py | 12 ++++++------ .../test/api/test_components/test_heat_consumer.py | 5 +---- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py b/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py index a1668ab38..31c013d45 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wzerolength_models.py @@ -4,7 +4,7 @@ from pandapipes.component_models.abstract_models.branch_wo_internals_models import \ BranchWOInternalsComponent -from pandapipes.idx_branch import LENGTH, K +from pandapipes.idx_branch import LENGTH, K, TEXT, ALPHA try: import pandaplan.core.pplog as logging @@ -58,6 +58,8 @@ def create_pit_branch_entries(cls, net, branch_pit): super().create_pit_branch_entries(net, branch_pit) branch_wzerolength_pit[:, LENGTH] = 0 branch_wzerolength_pit[:, K] = 1000 + branch_wzerolength_pit[:, TEXT] = 293.15 + branch_wzerolength_pit[:, ALPHA] = 0 return branch_wzerolength_pit @classmethod diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 5fef84f36..89cd5d900 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -70,9 +70,7 @@ def create_pit_branch_entries(cls, net, branch_pit): hs_pit[:, AREA] = hs_pit[:, D] ** 2 * np.pi / 4 hs_pit[:, VINIT] = (net[cls.table_name()].controlled_mdot_kg_per_s.values / (hs_pit[:, AREA] * hs_pit[:, RHO])) - hs_pit[:, ALPHA] = 0 hs_pit[:, QEXT] = net[cls.table_name()].qext_w.values - hs_pit[:, TEXT] = 293.15 return hs_pit @classmethod @@ -179,12 +177,12 @@ def get_component_input(cls): return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), + ("qext_w", "f8"), ("controlled_mdot_kg_per_s", "f8"), - ("qext_w", 'f8'), - ("deltat_k", 'f8'), - ("treturn_k", 'f8'), + ("deltat_k", "f8"), + ("treturn_k", "f8"), ("diameter_m", "f8"), - ("in_service", 'bool'), + ("in_service", "bool"), ("type", dtype(object))] @classmethod diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index 5dc36d0cb..cbcaef46f 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -9,7 +9,7 @@ from pandapipes.component_models.abstract_models.branch_wzerolength_models import \ BranchWZeroLengthComponent from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import ALPHA, TEXT, QEXT, D, AREA, LOSS_COEFFICIENT as LC, TOUTINIT +from pandapipes.idx_branch import QEXT, 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 @@ -55,10 +55,7 @@ def create_pit_branch_entries(cls, 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[:, TOUTINIT] = 307 @classmethod def extract_results(cls, net, options, branch_results, mode): diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 5dc012b6c..94bb7d02f 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1081,9 +1081,9 @@ def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=Non _check_branch(net, "Heat consumer", index, from_junction, to_junction) v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, - "qext_w": qext_w, "deltat_k": deltat_k, "treturn_k": treturn_k, - "in_service": bool(in_service), "type": type} + "diameter_m": diameter_m, "qext_w": qext_w, + "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_entries(net, "heat_consumer", index, **v, **kwargs) return index @@ -1765,9 +1765,9 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= _check_branches(net, from_junctions, to_junctions, "heat_consumer") entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, - "qext_w": qext_w, "deltat_k": deltat_k, "treturn_k": treturn_k, - "in_service": bool(in_service), "type": type} + "diameter_m": diameter_m, "qext_w": qext_w, + "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_multiple_entries(net, "heat_consumer", index, **entries, **kwargs) return index diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index d5a1dc023..491a117a5 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -166,7 +166,4 @@ def test_heat_consumer_creation_not_allowed_2(simple_heat_net): if __name__ == '__main__': - pd.set_option("display.width", 1000) - pd.set_option("display.max_columns", 45) - pd.set_option("display.max_colwidth", 100) - pd.set_option("display.max_rows", 200) + pytest.main([__file__]) From 9bd89c8ae6617a241e5f19594da5e6fc0628d9f6 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 9 Apr 2024 12:49:00 +0200 Subject: [PATCH 131/237] change order of mdot and qext in heat consumer creation docstrings --- src/pandapipes/create.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 94bb7d02f..e1c09b81c 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1036,11 +1036,11 @@ def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=Non :type to_junction: int :param diameter_m: The heat consumer inner diameter in [m] - only for result calculation :type diameter_m: float - :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. - :type controlled_mdot_kg_per_s: float, default None :param qext_w: External heat flux in [W]. If positive, heat is extracted from the network. If \ negative, heat is being fed into the network from a heat source. :type qext_w: float, default None + :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. + :type controlled_mdot_kg_per_s: float, default None :param deltat_k: Temperature difference set point between flow and return in [K]. :type deltat_k: float, default None :param treturn_k: Return temperature set point in [K]. @@ -1715,11 +1715,11 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= :type to_junctions: Iterable(int) :param diameter_m: The heat consumers' inner diameter in [m] - only for result calculation :type diameter_m: Iterable(float) or float - :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. - :type controlled_mdot_kg_per_s: Iterable(float) or float, default None :param qext_w: External heat flux in [W]. If positive, heat is extracted from the network. If \ negative, heat is being fed into the network from a heat source. :type qext_w: Iterable(float) or float, default None + :param controlled_mdot_kg_per_s: Mass flow set point in [kg/s]. + :type controlled_mdot_kg_per_s: Iterable(float) or float, default None :param deltat_k: Temperature difference set point between flow and return in [K]. :type deltat_k: Iterable(float) or float, default None :param treturn_k: Return temperature set point in [K]. From 17735d27aa90246dcec990f0fbbac3cebda2c261 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 12:52:21 +0200 Subject: [PATCH 132/237] differentiating between max_iter_hyd and max_iter_therm and iter. iter is general specification, however, is overwritten by max_iter_hyd and max_iter_therm if given. --- src/pandapipes/pf/pipeflow_setup.py | 28 ++++++++++- .../test/pipeflow_internals/test_options.py | 50 ++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index b94f99de4..78d33e2e8 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -291,7 +291,9 @@ def init_options(net, local_parameters): # the third layer is the user defined pipeflow options if "user_pf_options" in net and len(net.user_pf_options) > 0: - net["_options"].update(net.user_pf_options) + opts = _iteration_check(net.user_pf_options) + net["_options"].update(opts) + # the last layer is the layer of passeed parameters by the user, it is defined as the local # existing parameters during the pipeflow call which diverges from the default parameters of the @@ -301,7 +303,9 @@ def init_options(net, local_parameters): if k in excluded_params or (k in pf_func_options and pf_func_options[k] == v): continue params[k] = v - params.update(local_parameters["kwargs"]) + + opts = _iteration_check(local_parameters["kwargs"]) + params.update(opts) net["_options"].update(params) net["_options"]["fluid"] = get_fluid(net).name if not net["_options"]["only_update_hydraulic_matrix"]: @@ -313,6 +317,26 @@ def init_options(net, local_parameters): " flag to True. The pipeflow will be performed without numba speedup.") net["_options"]["use_numba"] = False +def _iteration_check(opts): + opts = copy.deepcopy(opts) + iter_defined = False + params = dict() + if 'iter' in opts: + params['max_iter_hyd'] = params['max_iter_therm'] = opts["iter"] + iter_defined = True + if 'max_iter_hyd' in opts: + max_iter_hyd = opts["max_iter_hyd"] + if iter_defined: logger.info("You defined 'iter' and 'max_iter_hyd. " + "'max_iter_hyd' will overwrite 'iter'") + params['max_iter_hyd'] = max_iter_hyd + if 'max_iter_therm' in opts: + max_iter_therm = opts["max_iter_therm"] + if iter_defined: logger.info("You defined 'iter' and 'max_iter_therm. " + "'max_iter_therm' will overwrite 'iter'") + params['max_iter_therm'] = max_iter_therm + opts.update(params) + return opts + def create_internal_results(net): """ diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index 1129d2657..416ac7de2 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -2,10 +2,13 @@ # 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 pandapipes.pf.pipeflow_setup -import pandapipes import copy + import pytest + +import pandapipes +import pandapipes.pf.pipeflow_setup +from pandapipes.pf.pipeflow_setup import PipeflowNotConverged from pandapipes.test.pipeflow_internals.test_inservice import create_test_net @@ -63,5 +66,48 @@ def test_set_user_pf_options(create_test_net, use_numba): assert net._options['tol_m'] == 1e-6 +@pytest.mark.parametrize("use_numba", [True, False]) +def test_iter(create_test_net, use_numba): + """ + + :param create_test_net: + :type create_test_net: + :return: + :rtype: + """ + net = copy.deepcopy(create_test_net) + pandapipes.create_fluid_from_lib(net, "water") + + max_iter_hyd = 3 if use_numba else 3 + max_iter_therm = 3 if use_numba else 3 + + pandapipes.set_user_pf_options(net, iter=2) + + with pytest.raises(PipeflowNotConverged): + pandapipes.pipeflow(net, mode='all') + + pandapipes.pipeflow(net, mode='hydraulics', max_iter_hyd=max_iter_hyd) + + with pytest.raises(PipeflowNotConverged): + pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd) + + pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + + pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd) + pandapipes.pipeflow(net, mode='hydraulics') + + with pytest.raises(PipeflowNotConverged): + pandapipes.pipeflow(net, mode='all') + + pandapipes.set_user_pf_options(net, max_iter_therm=max_iter_therm) + + pandapipes.pipeflow(net, mode='all') + + pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + + with pytest.raises(PipeflowNotConverged): + pandapipes.pipeflow(net, mode='all', iter=2) + + if __name__ == '__main__': pytest.main(["test_options.py"]) From a347b82da16a910cc873ccec8f9cc4a7083615a8 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 9 Apr 2024 12:53:20 +0200 Subject: [PATCH 133/237] spelling correction --- src/pandapipes/create.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index e1c09b81c..bf05b253a 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1753,8 +1753,8 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= var_sums[i] = np.full_like(from_junctions, pd.isnull(cv)).astype(np.int32) if np.any(np.sum(var_sums, axis=0) != 2): raise AttributeError(r"Define exactly two variables from 'controlled_mdot_kg_per_s', " - r"'qext_w' and 'deltat_k' or 'treturn_k' different from Nonefor each" - r" heat consumer.") + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None for " + r"each heat consumer.") if np.any(pd.notnull(deltat_k) & pd.notnull(treturn_k)): raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " r"flow temperature is independent of the heat consumer model.") From 273af7bc2a6ccfe8b0d6d41ecc86a62db747677d Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 13:58:53 +0200 Subject: [PATCH 134/237] Changelog started --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ca1e873ce..4eeb18c76 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Change Log ============= +[0.10.0] - 2024-04-09 +------------------------------- +- [CHANGED] moving generalizing pit entries up from specific components to the abstract class +- [FIXED] in circulation pumps only junctions in-service are considered + [0.9.0] - 2023-12-22 ------------------------------- From 3a9c5a239b77426a785947d52c4f2876a105b673 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 14:26:29 +0200 Subject: [PATCH 135/237] in heat consumer considering change from vinit to minit --- .../component_models/heat_consumer_component.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 89cd5d900..f2f4aaf71 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -8,8 +8,8 @@ from pandapipes.component_models import get_fluid, \ BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import (D, AREA, VINIT, ALPHA, QEXT, RHO, TEXT, JAC_DERIV_DP1, - JAC_DERIV_DV, JAC_DERIV_DP, LOAD_VEC_BRANCHES) +from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, \ + JAC_DERIV_DM, JAC_DERIV_DP, LOAD_VEC_BRANCHES from pandapipes.pf.result_extraction import extract_branch_results_without_internals @@ -68,8 +68,7 @@ def create_pit_branch_entries(cls, net, branch_pit): hs_pit = super().create_pit_branch_entries(net, branch_pit) hs_pit[:, D] = net[cls.table_name()].diameter_m.values hs_pit[:, AREA] = hs_pit[:, D] ** 2 * np.pi / 4 - hs_pit[:, VINIT] = (net[cls.table_name()].controlled_mdot_kg_per_s.values / - (hs_pit[:, AREA] * hs_pit[:, RHO])) + hs_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values hs_pit[:, QEXT] = net[cls.table_name()].qext_w.values return hs_pit @@ -127,7 +126,7 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo mdot_controlled = ~np.isnan(fc_array[:, cls.MASS]) fc_branch_pit[mdot_controlled, JAC_DERIV_DP] = 0 fc_branch_pit[mdot_controlled, JAC_DERIV_DP1] = 0 - fc_branch_pit[mdot_controlled, JAC_DERIV_DV] = 1 + fc_branch_pit[mdot_controlled, JAC_DERIV_DM] = 1 fc_branch_pit[mdot_controlled, LOAD_VEC_BRANCHES] = 0 # @classmethod From 8ea85045afce7624dbb2cc58e57de533ed974c9f Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 14:32:42 +0200 Subject: [PATCH 136/237] bugfix in tutorials --- tutorials/temperature_calculation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/temperature_calculation.ipynb b/tutorials/temperature_calculation.ipynb index b57c8c33a..ea88bead0 100644 --- a/tutorials/temperature_calculation.ipynb +++ b/tutorials/temperature_calculation.ipynb @@ -134,7 +134,7 @@ "# run pipeflow\n", "pandapipes.pipeflow(net, stop_condition=\"tol\", iter=3, friction_model=\"colebrook\",\n", " mode=\"all\", transient=False, nonlinear_method=\"automatic\", tol_p=1e-4,\n", - " tol_v=1e-4)" + " tol_m=1e-4)" ] }, { From 5b5547ce645b247ed616ddbc6c042ff2da38f70e Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 9 Apr 2024 14:38:20 +0200 Subject: [PATCH 137/237] bugfix in tutorials --- tutorials/temperature_calculation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/temperature_calculation.ipynb b/tutorials/temperature_calculation.ipynb index ea88bead0..1cad6d87f 100644 --- a/tutorials/temperature_calculation.ipynb +++ b/tutorials/temperature_calculation.ipynb @@ -132,7 +132,7 @@ "outputs": [], "source": [ "# run pipeflow\n", - "pandapipes.pipeflow(net, stop_condition=\"tol\", iter=3, friction_model=\"colebrook\",\n", + "pandapipes.pipeflow(net, stop_condition=\"tol\", iter=5, friction_model=\"colebrook\",\n", " mode=\"all\", transient=False, nonlinear_method=\"automatic\", tol_p=1e-4,\n", " tol_m=1e-4)" ] From 2c1060b825da67a26050c2bf903bcf059078dca6 Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 9 Apr 2024 15:15:57 +0200 Subject: [PATCH 138/237] prepared 0.10.0 release --- CHANGELOG.rst | 14 + doc/source/conf.py | 4 +- setup.py | 4 +- src/pandapipes/__init__.py | 4 +- .../api/old_versions/example_0.10.0_gas.json | 458 +++++++++++++++ .../old_versions/example_0.10.0_water.json | 520 ++++++++++++++++++ .../release_control_test_network.py | 5 +- 7 files changed, 1001 insertions(+), 8 deletions(-) create mode 100644 src/pandapipes/test/api/old_versions/example_0.10.0_gas.json create mode 100644 src/pandapipes/test/api/old_versions/example_0.10.0_water.json diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4eeb18c76..3e79f9eb2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,21 @@ Change Log [0.10.0] - 2024-04-09 ------------------------------- + +- [ADDED] function for plotting pressure profile +- [ADDED] function for calculating distance to junctions +- [ADDED] topology function for returning unsupplied junctions +- [ADDED] topology function for returning elements on path +- [ADDED] function for getting all branch-component table names +- [ADDED] function for getting all branch-component models +- [ADDED] component 'heat_consumer' that combines the two components heat_exchanger and flow_control - [CHANGED] moving generalizing pit entries up from specific components to the abstract class +- [CHANGED] 'JAC_DERIV_DT1' to 'JAC_DERIV_DTOUT' +- [CHANGED] solving for minit instead of vinit +- [CHANGED] distinct max. iteration settings for hydraulic and thermal calculation +- [CHANGED] default tolerances from 1e-4 to 1e-5 +- [FIXED] results of old grid are wrong, pipeflow needs to be conducted again +- [FIXED] taking norm density instead of real density in Darcy-Weisbach equation - [FIXED] in circulation pumps only junctions in-service are considered [0.9.0] - 2023-12-22 diff --git a/doc/source/conf.py b/doc/source/conf.py index f534b111f..31072d076 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -47,9 +47,9 @@ # built documents. # # The short X.Y version. -version = "0.9" +version = "0.10" # The full version, including alpha/beta/rc tags. -release = "0.9.0" +release = "0.10.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index cad8d74c7..b29abc6eb 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup( name='pandapipes', - version='0.9.0', + version='0.10.0', author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' 'jolando.kisse@uni-kassel.de', @@ -44,7 +44,7 @@ long_description_content_type='text/x-rst', url='http://www.pandapipes.org', license='BSD', - install_requires=["pandapower>=2.13.1", "matplotlib", "shapely"], + install_requires=["pandapower>=2.14.6", "matplotlib", "shapely"], extras_require={"docs": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex"], "plotting": ["plotly", "igraph"], "test": ["pytest", "pytest-xdist", "nbmake"], diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index 14463e7aa..f8e6f2dec 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -2,8 +2,8 @@ # 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. -__version__ = '0.9.0' -__format_version__ = '0.8.0' +__version__ = '0.10.0' +__format_version__ = '0.10.0' import pandas as pd import os diff --git a/src/pandapipes/test/api/old_versions/example_0.10.0_gas.json b/src/pandapipes/test/api/old_versions/example_0.10.0_gas.json new file mode 100644 index 000000000..aeb0a764f --- /dev/null +++ b/src/pandapipes/test/api/old_versions/example_0.10.0_gas.json @@ -0,0 +1,458 @@ +{ + "_module": "pandapipes.pandapipes_net", + "_class": "pandapipesNet", + "_object": { + "fluid": { + "_module": "pandapipes.properties.fluids", + "_class": "Fluid", + "_object": "{\"name\": \"hgas\", \"fluid_type\": \"gas\", \"is_gas\": true, \"all_properties\": {\"density\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.7614762591064257}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.733332277439119}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.7072104923835694}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6828947600611692}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.660205611537355}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6389854855679075}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6190946329317856}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 0.6004074588524487}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"viscosity\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0047118361853041e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.04021750220461e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0704866480048474e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.1007402297863992e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.1337005139349375e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.170765177634217e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.2010332619395079e-05}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.231274052527204e-05}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"heat_capacity\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyInterExtra\", \"_object\": \"{\\\"x\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 263.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 273.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 283.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 293.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 303.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 313.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 323.0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 333.0}], \\\"dtype\\\": \\\"float64\\\"}, \\\"y\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2111.7430409177705}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2129.19525821288}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2148.5756908384515}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2169.8204812997346}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2192.8111461983763}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2217.455354914997}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2243.67904088272}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 2271.295613279192}], \\\"dtype\\\": \\\"float64\\\"}, \\\"_fill_value_orig\\\": \\\"extrapolate\\\"}\"}, \"molar_mass\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 16.604497, \\\"warn_dependent_variables\\\": false}\"}, \"der_compressibility\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": -0.0022, \\\"warn_dependent_variables\\\": false}\"}, \"compressibility\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyLinear\", \"_object\": \"{\\\"slope\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": -0.0022}, \\\"offset\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"float64\\\", \\\"_object\\\": 1.0}}\"}, \"lhv\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 13.20179, \\\"warn_dependent_variables\\\": false}\"}, \"hhv\": {\"_module\": \"pandapipes.properties.fluids\", \"_class\": \"FluidPropertyConstant\", \"_object\": \"{\\\"value\\\": 14.62197, \\\"warn_dependent_variables\\\": false}\"}}}" + }, + "converged": true, + "name": "net", + "version": "0.10.0", + "format_version": "0.10.0", + "component_list": [ + { + "_module": "pandapipes.component_models.junction_component", + "_class": "Junction", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.pipe_component", + "_class": "Pipe", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.ext_grid_component", + "_class": "ExtGrid", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.sink_component", + "_class": "Sink", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.source_component", + "_class": "Source", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.mass_storage_component", + "_class": "MassStorage", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.valve_component", + "_class": "Valve", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.flow_control_component", + "_class": "FlowControlComponent", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.pressure_control_component", + "_class": "PressureControlComponent", + "_object": "{}" + }, + { + "_module": "pandapipes.component_models.compressor_component", + "_class": "Compressor", + "_object": "{}" + } + ], + "junction": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"pn_bar\",\"tfluid_k\",\"height_m\",\"in_service\",\"type\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12],\"data\":[[\"Junction 0\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 1\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 2\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 3\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 4\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 5\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 6\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 7\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 8\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 9\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 10\",16.0,283.0,0.0,true,\"junction\"],[\"Junction 11\",0.7,283.0,0.0,true,\"junction\"],[\"Junction 12\",0.7,283.0,0.0,true,\"junction\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "pn_bar": "float64", + "tfluid_k": "float64", + "height_m": "float64", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "junction_geodata": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"x\",\"y\"],\"index\":[],\"data\":[]}", + "orient": "split", + "dtype": { + "x": "float64", + "y": "float64" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "pipe": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"from_junction\",\"to_junction\",\"std_type\",\"length_km\",\"diameter_m\",\"k_mm\",\"loss_coefficient\",\"alpha_w_per_m2k\",\"text_k\",\"qext_w\",\"sections\",\"in_service\",\"type\"],\"index\":[0,1,2,3,4,5,6,7],\"data\":[[\"Pipe 0\",0,1,null,3.0,0.1,1.0,0.0,10.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 1\",2,3,null,6.0,0.075,0.1,0.0,3.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 2\",3,4,null,5.0,0.06,0.1,0.0,20.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 3\",4,5,null,0.1,0.07,0.1,0.0,2.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 4\",5,6,null,4.5,0.085,0.1,0.0,2.5,293.0,0.0,10,true,\"pipe\"],[\"Pipe 5\",8,7,null,4.0,0.03,0.1,0.0,1.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 6\",9,10,null,1.0,0.03,0.1,0.0,1.0,293.0,0.0,10,true,\"pipe\"],[\"Pipe 7\",11,12,null,1.5,0.09,0.1,0.0,3.0,293.0,0.0,10,true,\"pipe\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "from_junction": "uint32", + "to_junction": "uint32", + "std_type": "object", + "length_km": "float64", + "diameter_m": "float64", + "k_mm": "float64", + "loss_coefficient": "float64", + "alpha_w_per_m2k": "float64", + "text_k": "float64", + "qext_w": "float64", + "sections": "uint32", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "pipe_geodata": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"coords\"],\"index\":[],\"data\":[]}", + "orient": "split", + "dtype": { + "coords": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "ext_grid": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"name\",\"junction\",\"p_bar\",\"t_k\",\"in_service\",\"type\"],\"index\":[0,1],\"data\":[[\"External Grid 0\",0,16.0,280.0,true,\"pt\"],[\"External Grid 1\",8,15.0,285.0,true,\"pt\"]]}", + "orient": "split", + "dtype": { + "name": "object", + "junction": "uint32", + "p_bar": "float64", + "t_k": "float64", + "in_service": "bool", + "type": "object" + }, + "is_multiindex": false, + "is_multicolumn": false + }, + "controller": { + "_module": "pandas.core.frame", + "_class": "DataFrame", + "_object": "{\"columns\":[\"object\",\"in_service\",\"order\",\"level\",\"initial_run\",\"recycle\"],\"index\":[0,1],\"data\":[[{\"_module\":\"pandapower.control.controller.const_control\",\"_class\":\"ConstControl\",\"_object\":\"{\\\"index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, \\\"matching_params\\\": {\\\"element\\\": \\\"sink\\\", \\\"variable\\\": \\\"mdot_kg_per_s\\\", \\\"element_index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 1}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 2}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 3}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 4}], \\\"dtype\\\": \\\"int64\\\"}}, \\\"data_source\\\": {\\\"_module\\\": \\\"pandapower.timeseries.data_sources.frame_data\\\", \\\"_class\\\": \\\"DFData\\\", \\\"_object\\\": \\\"{\\\\\\\"df\\\\\\\": {\\\\\\\"_module\\\\\\\": \\\\\\\"pandas.core.frame\\\\\\\", \\\\\\\"_class\\\\\\\": \\\\\\\"DataFrame\\\\\\\", \\\\\\\"_object\\\\\\\": \\\\\\\"{\\\\\\\\\\\\\\\"columns\\\\\\\\\\\\\\\":[\\\\\\\\\\\\\\\"0\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"1\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"2\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"3\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"4\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"5\\\\\\\\\\\\\\\"],\\\\\\\\\\\\\\\"index\\\\\\\\\\\\\\\":[0,1,2,3],\\\\\\\\\\\\\\\"data\\\\\\\\\\\\\\\":[[0.2,0.1,0.5,0.07,0.09,0.1],[0.3,0.2,0.6,0.08,0.1,0.2],[0.4,0.3,0.7,0.09,0.11,0.3],[0.5,0.4,0.8,0.1,0.12,0.4]]}\\\\\\\", \\\\\\\"orient\\\\\\\": \\\\\\\"split\\\\\\\", \\\\\\\"dtype\\\\\\\": {\\\\\\\"0\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"1\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"2\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"3\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"4\\\\\\\": \\\\\\\"float64\\\\\\\", \\\\\\\"5\\\\\\\": \\\\\\\"float64\\\\\\\"}, \\\\\\\"is_multiindex\\\\\\\": false, \\\\\\\"is_multicolumn\\\\\\\": false}}\\\"}, \\\"element_index\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [{\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 0}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 1}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 2}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 3}, {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"int64\\\", \\\"_object\\\": 4}], \\\"dtype\\\": \\\"int64\\\"}, \\\"element\\\": \\\"sink\\\", \\\"values\\\": null, \\\"profile_name\\\": {\\\"_module\\\": \\\"numpy\\\", \\\"_class\\\": \\\"array\\\", \\\"_object\\\": [\\\"0\\\", \\\"1\\\", \\\"2\\\", \\\"3\\\", \\\"4\\\"], \\\"dtype\\\": \\\" Date: Thu, 11 Apr 2024 09:07:43 +0200 Subject: [PATCH 139/237] -added heat_consumer patch --- src/pandapipes/plotting/collections.py | 53 ++++++++++++++++++++- src/pandapipes/plotting/patch_makers.py | 47 +++++++++++++++++- src/pandapipes/plotting/plotting_toolbox.py | 5 +- src/pandapipes/plotting/simple_plot.py | 32 ++++++++++--- 4 files changed, 127 insertions(+), 10 deletions(-) diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index 144b64d63..8be68e443 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -9,7 +9,7 @@ add_cmap_to_collection, coords_from_node_geodata from pandapower.plotting.patch_makers import load_patches, ext_grid_patches from pandapipes.plotting.patch_makers import valve_patches, source_patches, heat_exchanger_patches, \ - pump_patches, pressure_control_patches, compressor_patches, flow_control_patches + pump_patches, pressure_control_patches, compressor_patches, flow_control_patches, heat_consumer_patches from pandapower.plotting.plotting_toolbox import get_index_array try: @@ -664,4 +664,55 @@ def create_compressor_collection(net, cmprs=None, table_name='compressor', size= patch_edgecolor=color, line_color=color, **kwargs) + return pc, lc + +def create_heat_consumer_collection(net, hec=None, table_name='heat_consumer', size=5., + junction_geodata=None, color='k', infofunc=None, picker=False, + **kwargs): + """ + Creates a matplotlib patch collection of pandapipes compressors. Compressors are + plotted in the center between two junctions. + + :param net: The pandapipes network + :type net: pandapipesNet + :param hec: The heat consumers for which the collections are created. If None, all heat consumers + which have entries in the respective junction geodata will be plotted. + :type hec: list, default None + :param size: Patch size + :type size: float, default 5. + :param junction_geodata: Coordinates to use for plotting. If None, net["junction_geodata"] is \ + used. + :type junction_geodata: pandas.DataFrame, default None + :param colors: Color or list of colors for every compressor + :type colors: iterable, float, default None + :param infofunc: infofunction for the patch element + :type infofunc: function, default None + :param picker: Picker argument passed to the patch collection + :type picker: bool, default False + :param kwargs: Keyword arguments are passed to the patch function + :return: lc - line collection, pc - patch collection + + """ + hec = get_index_array(hec, net[table_name].index) + hec_table = net[table_name].loc[hec] + + coords, hec_with_geo = coords_from_node_geodata( + hec, hec_table.from_junction.values, hec_table.to_junction.values, + junction_geodata if junction_geodata is not None else net["junction_geodata"], table_name, + "Junction") + + if len(hec_with_geo) == 0: + return None + + linewidths = kwargs.pop("linewidths", 2.) + linewidths = kwargs.pop("linewidth", linewidths) + linewidths = kwargs.pop("lw", linewidths) + + infos = list(np.repeat([infofunc(i) for i in range(len(cmprs_with_geo))], 2)) \ + if infofunc is not None else [] + pc, lc = _create_complex_branch_collection(coords, heat_consumer_patches, size, infos, + picker=picker, linewidths=linewidths, + patch_edgecolor=color, line_color=color, + **kwargs) + return pc, lc \ No newline at end of file diff --git a/src/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py index 3c6950ca0..0389f630e 100644 --- a/src/pandapipes/plotting/patch_makers.py +++ b/src/pandapipes/plotting/patch_makers.py @@ -3,7 +3,7 @@ # 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 matplotlib.patches import RegularPolygon, Rectangle, Circle, PathPatch, FancyArrow +from matplotlib.patches import RegularPolygon, Rectangle, Circle, PathPatch, FancyArrow, Polygon from matplotlib.path import Path from pandapower.plotting.plotting_toolbox import get_color_list, _rotate_dim2, get_angle_list, \ get_list @@ -218,3 +218,48 @@ def pressure_control_patches(coords, size, **kwargs): lines.append([plr, pur]) return lines, polys, {} + +def heat_consumer_patches(coords, size, **kwargs): + polys, lines = [], [] + facecolor = kwargs.get("patch_facecolor", "w") + edgecolor = kwargs.get("patch_edgecolor", "k") + facecolors = get_color_list(facecolor, len(coords)) + edgecolors = get_color_list(edgecolor, len(coords)) + lw = kwargs.get("linewidths", 2.) + + for geodata, face_col, edge_col in zip(coords, facecolors, edgecolors): + p1, p2 = np.array(geodata[0]), np.array(geodata[-1]) + diff = p2 - p1 + m = 3 * size / 4 + direc = diff / np.sqrt(diff[0] ** 2 + diff[1] ** 2) + normal = np.array([-direc[1], direc[0]]) + path1 = (p1 + diff / 2 + direc * m / 2) + normal * (size * 9 / 8) + path2 = p1 + diff / 2 + direc * m / 2 + path3 = p1 + diff / 2 + normal * size / 3 + path4 = p1 + diff / 2 - direc * m / 2 + path5 = (p1 + diff / 2 - direc * m / 2) + normal * (size * 9 / 8) + path = [path1, path2, path3, path4, path5] + radius = size # np.sqrt(diff[0]**2+diff[1]**2)/15 + + pa = Path(path) + polys.append(Circle(p1 + diff / 2, radius=radius, edgecolor=edge_col, facecolor=face_col, + lw=lw)) + polys.append(PathPatch(pa, fill=False, lw=lw, edgecolor=edge_col)) + + # Calculate the endpoints of the line segments passing through the circle + circle_center = p1 + diff / 2 + line1_start = p1 + line1_end = circle_center - direc * radius + line2_start = circle_center + direc * radius + line2_end = p2 + + # Append the line segments to the list of lines + lines.append([line1_start, line1_end]) + lines.append([line2_start, line2_end]) + + # Connect the line passing through the circle with the main line + connect_line_start = line1_end + connect_line_end = line2_start + lines.append([connect_line_start, connect_line_end]) + + return lines, polys, {} diff --git a/src/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py index 23b5817ec..69e183a8a 100644 --- a/src/pandapipes/plotting/plotting_toolbox.py +++ b/src/pandapipes/plotting/plotting_toolbox.py @@ -4,7 +4,7 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1.0, source_size=1.0, valve_size=2.0, pump_size=1.0, heat_exchanger_size=1.0, - pressure_control_size=1.0, compressor_size=1.0, flow_control_size=1.0): + pressure_control_size=1.0, compressor_size=1.0, flow_control_size=1.0, heat_consumer_size=1.0): """ Calculates the size for most collection types according to the distance between min and max geocoord so that the collections fit the plot nicely @@ -26,6 +26,8 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. :type valve_size: float, default 2. :param heat_exchanger_size: relative heat exchanger size :type heat_exchanger_size: float, default 1. + :param heat_consumer_size: relative heat consumer size + :type heat_consumer_size: float, default 1. :return: sizes (dict) - dictionary containing all scaled sizes """ mean_distance_between_junctions = sum((net['junction_geodata'].max() - net[ @@ -42,6 +44,7 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. "pressure_control": pressure_control_size * mean_distance_between_junctions * 8, "compressor": compressor_size * mean_distance_between_junctions * 8, "flow_control": flow_control_size * mean_distance_between_junctions * 2, + "heat_consumer": heat_consumer_size * mean_distance_between_junctions*2 } return sizes diff --git a/src/pandapipes/plotting/simple_plot.py b/src/pandapipes/plotting/simple_plot.py index 1d0902369..73ef01d93 100644 --- a/src/pandapipes/plotting/simple_plot.py +++ b/src/pandapipes/plotting/simple_plot.py @@ -13,7 +13,7 @@ from pandapipes.plotting.collections import create_junction_collection, create_pipe_collection, \ create_valve_collection, create_source_collection, create_pressure_control_collection, \ create_heat_exchanger_collection, create_sink_collection, create_pump_collection, \ - create_compressor_collection, create_flow_control_collection + create_compressor_collection, create_flow_control_collection, create_heat_consumer_collection from pandapipes.plotting.generic_geodata import create_generic_coordinates from pandapipes.plotting.plotting_toolbox import get_collection_sizes @@ -29,10 +29,10 @@ def simple_plot(net, respect_valves=False, respect_in_service=True, pipe_width=2 junction_size=1.0, ext_grid_size=1.0, plot_sinks=False, plot_sources=False, sink_size=1.0, source_size=1.0, valve_size=1.0, pump_size=1.0, heat_exchanger_size=1.0, pressure_control_size=1.0, compressor_size=1.0, flow_control_size=1.0, - scale_size=True, junction_color="r", pipe_color='silver', ext_grid_color='orange', - valve_color='silver', pump_color='silver', heat_exchanger_color='silver', + heat_consumer_size=1.0, scale_size=True, junction_color="r", pipe_color='silver', + ext_grid_color='orange', valve_color='silver', pump_color='silver', heat_exchanger_color='silver', pressure_control_color='silver', compressor_color='silver', flow_control_color='silver', - library="igraph", show_plot=True, ax=None, **kwargs): + heat_consumer_color='silver',library="igraph", show_plot=True, ax=None, **kwargs): """ Plots a pandapipes network as simple as possible. If no geodata is available, artificial geodata is generated. For advanced plotting see @@ -74,6 +74,8 @@ def simple_plot(net, respect_valves=False, respect_in_service=True, pipe_width=2 :type compressor_size: float, default 1.0 :param flow_control_size: Relative size of flow_control to plot. :type flow_control_size: float, default 1.0 + :param heat_consumer_size: Relative size of heat_consumer to plot. + :type heat_consumer_size: float, default 1.0 :param scale_size: Flag if junction_size, ext_grid_size, valve_size- and distance will be \ scaled with respect to grid mean distances :type scale_size: bool, default True @@ -96,6 +98,8 @@ def simple_plot(net, respect_valves=False, respect_in_service=True, pipe_width=2 :type compressor_color: str, tuple, default "silver" :param flow_control_color: Flow Control Color. :type flow_control_color: str, tuple, default "silver" + :param heat_consumer_color: heat_consumer Color. + :type heat_consumer_color: str, tuple, default "silver" :param library: Library name to create generic coordinates (case of missing geodata). Choose\ "igraph" to use igraph package or "networkx" to use networkx package. :type library: str, default "igraph" @@ -122,6 +126,7 @@ def simple_plot(net, respect_valves=False, respect_in_service=True, pipe_width=2 pressure_control_size=pressure_control_size, compressor_size=compressor_size, flow_control_size=flow_control_size, + heat_consumer_size=heat_consumer_size, scale_size=scale_size, junction_color=junction_color, pipe_color=pipe_color, @@ -132,6 +137,7 @@ def simple_plot(net, respect_valves=False, respect_in_service=True, pipe_width=2 pressure_control_color=pressure_control_color, compressor_color=compressor_color, flow_control_color=flow_control_color, + heat_consumer_color=heat_consumer_color, library=library, as_dict=False, **kwargs) ax = draw_collections(collections, ax=ax) @@ -145,11 +151,11 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True junction_size=1.0, ext_grid_size=1.0, plot_sinks=False, plot_sources=False, sink_size=1.0, source_size=1.0, valve_size=1.0, pump_size=1.0, heat_exchanger_size=1.0, pressure_control_size=1.0, - compressor_size=1.0, flow_control_size=1.0, + compressor_size=1.0, flow_control_size=1.0, heat_consumer_size=1.0, scale_size=True, junction_color="r", pipe_color='silver', ext_grid_color='orange', valve_color='silver', pump_color='silver', heat_exchanger_color='silver', pressure_control_color='silver', - compressor_color='silver', flow_control_color='silver', + compressor_color='silver', flow_control_color='silver', heat_consumer_color='silver', library="igraph", as_dict=True, **kwargs): """ Plots a pandapipes network as simple as possible. @@ -194,6 +200,8 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True :type compressor_size: float, default 1.0 :param flow_control_size: Relative size of flow_control to plot. :type flow_control_size: float, default 1.0 + :param heat_consumer_size: Relative size of heat_consumer to plot. + :type heat_consumer_size: float, default 1.0 :param scale_size: Flag if junction_size, ext_grid_size, valve_size- and distance will be \ scaled with respect to grid mean distances :type scale_size: bool, default True @@ -216,6 +224,8 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True :type compressor_color: str, tuple, default "silver" :param flow_control_color: Flow Control Color. :type flow_control_color: str, tuple, default "silver" + :param heat_consumer_color: heat_consumer Color. + :type heat_consumer_color: str, tuple, default "silver" :param library: library name to create generic coordinates (case of missing geodata). Choose\ "igraph" to use igraph package or "networkx" to use networkx package. **NOTE**: \ Currently the networkx implementation is not working! @@ -236,7 +246,7 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True # if scale_size -> calc size from distance between min and max geocoord sizes = get_collection_sizes( net, junction_size, ext_grid_size, sink_size, source_size, valve_size, pump_size, - heat_exchanger_size, pressure_control_size, compressor_size, flow_control_size) + heat_exchanger_size, pressure_control_size, compressor_size, flow_control_size, heat_consumer_size) junction_size = sizes["junction"] ext_grid_size = sizes["ext_grid"] source_size = sizes["source"] @@ -247,6 +257,7 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True pressure_control_size = sizes["pressure_control"] compressor_size = sizes["compressor"] flow_control_size = sizes["flow_control"] + heat_consumer_size = sizes["heat_consumer"] # create junction collections to plot junc_idx = net.junction[net.junction.in_service].index if respect_in_service \ @@ -340,6 +351,13 @@ def create_simple_collections(net, respect_valves=False, respect_in_service=True linewidths=pipe_width, color=compressor_color) collections["compressor"] = compr_colls + if 'heat_consumer' in net: + idx = net.heat_consumer[net.heat_consumer.in_service].index if respect_in_service \ + else net.heat_consumer.index + he_colls = create_heat_consumer_collection(net, idx, size=heat_consumer_size, + linewidths=pipe_width, color=heat_consumer_color) + collections["heat consumers"] = he_colls + if 'additional_collections' in kwargs: collections["additional"] = list() for collection in kwargs.pop('additional_collections'): From f4e2fd6bab4683726cebe5ea0a996a1b04c6d9ab Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:17:10 +0200 Subject: [PATCH 140/237] Update CHANGELOG.rst added heat consumer plotting --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3e79f9eb2..728476251 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,8 @@ Change Log ============= +-[ADDED] heat_consumer plotting + [0.10.0] - 2024-04-09 ------------------------------- From 9b98afcdb0228d0efda5d2ab602b9c29c3e06115 Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 11 Apr 2024 09:23:18 +0200 Subject: [PATCH 141/237] -fixed error --- src/pandapipes/plotting/collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index 8be68e443..61b304b06 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -708,7 +708,7 @@ def create_heat_consumer_collection(net, hec=None, table_name='heat_consumer', s linewidths = kwargs.pop("linewidth", linewidths) linewidths = kwargs.pop("lw", linewidths) - infos = list(np.repeat([infofunc(i) for i in range(len(cmprs_with_geo))], 2)) \ + infos = list(np.repeat([infofunc(i) for i in range(len(hec_with_geo))], 2)) \ if infofunc is not None else [] pc, lc = _create_complex_branch_collection(coords, heat_consumer_patches, size, infos, picker=picker, linewidths=linewidths, From 91bb6c8a99651f47f425355e0e4acbc935221b65 Mon Sep 17 00:00:00 2001 From: eprade Date: Fri, 12 Apr 2024 16:37:01 +0200 Subject: [PATCH 142/237] -changed alpha to u --- .../component_models/pipe_component.py | 4 +- .../converter/stanet/table_creation.py | 6 +- .../valve_pipe_component/create_valve_pipe.py | 16 +- .../valve_pipe_component.py | 2 +- src/pandapipes/create.py | 65 ++- src/pandapipes/io/convert_format.py | 3 + src/pandapipes/std_types/library/Pipe.csv | 460 +++++++++--------- .../release_control_test_network.py | 48 +- .../test/api/test_components/test_ext_grid.py | 64 +-- .../api/test_components/test_flow_control.py | 2 +- .../api/test_components/test_heat_consumer.py | 2 +- src/pandapipes/test/api/test_create.py | 36 +- .../test/api/test_network_tables.py | 2 +- src/pandapipes/test/api/test_std_types.py | 3 +- .../test/pipeflow_internals/test_inservice.py | 32 +- .../test_pipeflow_analytic_comparison.py | 42 +- .../pipeflow_internals/test_pipeflow_modes.py | 6 +- 17 files changed, 418 insertions(+), 375 deletions(-) diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 3492b6c79..a0376d201 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -112,7 +112,7 @@ def create_pit_branch_entries(cls, net, branch_pit): set_entry_check_repeat( pipe_pit, K, net[tbl].k_mm.values / 1000, internal_pipe_number, has_internals) set_entry_check_repeat( - pipe_pit, ALPHA, net[tbl].alpha_w_per_m2k.values, internal_pipe_number, has_internals) + pipe_pit, ALPHA, net[tbl].u_w_per_m2k.values, internal_pipe_number, has_internals) set_entry_check_repeat( pipe_pit, QEXT, net[tbl].qext_w.values, internal_pipe_number, has_internals) set_entry_check_repeat( @@ -264,7 +264,7 @@ def get_component_input(cls): ("diameter_m", "f8"), ("k_mm", "f8"), ("loss_coefficient", "f8"), - ("alpha_w_per_m2k", 'f8'), + ("u_w_per_m2k", 'f8'), ("text_k", 'f8'), ("qext_w", 'f8'), ("sections", "u4"), diff --git a/src/pandapipes/converter/stanet/table_creation.py b/src/pandapipes/converter/stanet/table_creation.py index 280d3a64a..3f2eb5301 100644 --- a/src/pandapipes/converter/stanet/table_creation.py +++ b/src/pandapipes/converter/stanet/table_creation.py @@ -602,7 +602,7 @@ def create_geodata_sections(row): net, pipe_sections.fj.values, pipe_sections.tj.values, pipe_sections.length.values / 1000, pipes.DM.values / 1000, pipes.RAU.values, pipes.ZETA.values, type="main_pipe", stanet_std_type=pipes.ROHRTYP.values, in_service=pipes.ISACTIVE.values, text_k=text_k, - alpha_w_per_m2k=alpha, + u_w_per_m2k=alpha, name=["pipe_%s_%s_%s" % (nf, nt, sec) for nf, nt, sec in zip( pipes.ANFNAM.values, pipes.ENDNAM.values, pipe_sections.section_no.values)], stanet_nr=pipes.RECNO.values, stanet_id=pipes.STANETID.values, @@ -735,7 +735,7 @@ def create_pipes_from_remaining_pipe_table(net, stored_data, connection_table, i loss_coefficient=p_tbl.ZETA.values, stanet_std_type=p_tbl.ROHRTYP.values, k_mm=p_tbl.RAU.values, in_service=p_tbl.ISACTIVE.values.astype(np.bool_), name=["pipe_%s_%s" % (anf, end) for anf, end in zip(from_names[valid], to_names[valid])], - alpha_w_per_m2k=alpha, text_k=text_k, stanet_nr=p_tbl.RECNO.values.astype(np.int32), + u_w_per_m2k=alpha, text_k=text_k, stanet_nr=p_tbl.RECNO.values.astype(np.int32), stanet_id=p_tbl.STANETID.values.astype(str), v_stanet=p_tbl.VM.values, geodata=geodata, stanet_system=CLIENT_TYPES_OF_PIPES[MAIN_PIPE_TYPE], stanet_active=p_tbl.ISACTIVE.values.astype(np.bool_), @@ -1055,7 +1055,7 @@ def create_geodata_sections(row): net, hp_data.fj.values, hp_data.tj.values, hp_data.length.values / 1000, hp_data.DM.values / 1000, hp_data.RAU.values, hp_data.ZETA.values, type="house_pipe", in_service=hp_data.ISACTIVE.values if houses_in_calculation else False, text_k=text_k, - alpha_w_per_m2k=alpha, geodata=hp_data.section_geo.values, + u_w_per_m2k=alpha, geodata=hp_data.section_geo.values, name=["pipe_%s_%s_%s" % (nf, nt, sec) for nf, nt, sec in zip( hp_data.CLIENTID.values, hp_data.CLIENT2ID.values, hp_data.section_no.values)], stanet_std_type=hp_data.ROHRTYP.values, stanet_nr=hp_data.RECNO.values, diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py b/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py index 8ab3fe6eb..b6c288540 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/create_valve_pipe.py @@ -11,7 +11,7 @@ def create_valve_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.15e-3, - opened=True, loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., + opened=True, loss_coefficient=0, sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="valve_pipe", **kwargs): """ Creates a valve pipe element in net["valve_pipe"] from valve pipe parameters. In any case the @@ -42,8 +42,8 @@ def create_valve_pipe(net, from_junction, to_junction, std_type, length_km, k_mm :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] - :type alpha_w_per_m2k: float, default 0 + :param u_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] + :type u_w_per_m2k: float, default 0 :param text_k: Ambient temperatures of pipes in [K] :type text_k: Iterable or float, default 293 :param qext_w: external heat feed-in to the pipe in [W] @@ -83,7 +83,7 @@ def create_valve_pipe(net, from_junction, to_junction, std_type, length_km, k_mm v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, "length_km": length_km, "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, "opened": opened, "loss_coefficient": loss_coefficient, - "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, + "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} _set_entries(net, "valve_pipe", index, **v, **kwargs) @@ -95,7 +95,7 @@ def create_valve_pipe(net, from_junction, to_junction, std_type, length_km, k_mm def create_valve_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.15e-3, - opened=True, loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, + opened=True, loss_coefficient=0, sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="valve_pipe", **kwargs): """ @@ -126,8 +126,8 @@ def create_valve_pipe_from_parameters(net, from_junction, to_junction, length_km :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] - :type alpha_w_per_m2k: float, default 0 + :param u_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] + :type u_w_per_m2k: float, default 0 :param text_k: Ambient temperatures of pipes in [K] :type text_k: Iterable or float, default 293 :param qext_w: external heat feed-in to the pipe in [W] @@ -165,7 +165,7 @@ def create_valve_pipe_from_parameters(net, from_junction, to_junction, length_km v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "opened": opened, "loss_coefficient": loss_coefficient, - "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, + "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} _set_entries(net, "valve_pipe", index, **v, **kwargs) diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py index 4dc085eb4..311a84d9f 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py @@ -69,7 +69,7 @@ def get_component_input(cls): ("max_vdot_m3_per_s", 'f8'), ("max_v_m_per_s", 'f8'), ("in_service", 'bool'), - ("alpha_w_per_m2k", 'f8'), + ("u_w_per_m2k", 'f8'), ("qext_w", 'f8'), ("type", dtype(object)), ('index', 'u4')] diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index bf05b253a..5f3d7f622 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -378,7 +378,7 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + sections=1, text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -401,8 +401,6 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] - :type alpha_w_per_m2k: float, default 0 :param text_k: Ambient temperature of pipe in [K] :type text_k: float, default 293 :param qext_w: External heat feed-in to the pipe in [W] @@ -439,8 +437,8 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, pipe_parameter = load_std_type(net, std_type, "pipe") v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, "length_km": length_km, - "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, + "diameter_m": pipe_parameter["inner_diameter_mm"]/1000 , "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "u_w_per_m2k": pipe_parameter['u_w_per_m2k'], "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} _set_entries(net, "pipe", index, **v, **kwargs) @@ -451,10 +449,9 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, return index -def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, - qext_w=0., name=None, index=None, geodata=None, in_service=True, - type="pipe", **kwargs): +def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, + sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, + in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -476,8 +473,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] - :type alpha_w_per_m2k: float, default 0 + :param u_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] + :type u_w_per_m2k: float, default 0 :param qext_w: external heat feed-in to the pipe in [W] :type qext_w: float, default 0 :param text_k: Ambient temperature of pipe in [K] @@ -501,8 +498,7 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam :rtype: int :Example: - >>> create_pipe_from_parameters(net, from_junction=0, to_junction=1, - >>> length_km=1, diameter_m=40e-3) + >>> create_pipe_from_parameters(net, from_junction=0, to_junction=1, length_km=1, diameter_m=40e-3) """ add_new_component(net, Pipe) @@ -512,9 +508,20 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, + "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} + #Check if alpha parameter was declared (Alpha has been changed to U) + if 'alpha_w_per_m2k' in kwargs: + u_w_per_m2k = alpa_w_per_m2k + + raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.' + ' In the future alpha will be renamed to u.' + ' Please define only one variable for the heat transfer coefficient. ' + 'u will be overwritten by alpha') + + + if 'std_type' in kwargs: raise UserWarning('you have defined a std_type, however, using this function you can only ' 'create a pipe setting specific, individual parameters. If you want to ' @@ -1294,7 +1301,7 @@ def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, ind def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., + loss_coefficient=0, sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ @@ -1321,8 +1328,8 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: Iterable or int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] - :type alpha_w_per_m2k: Iterable or float, default 0 + :param u_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] + :type u_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] :type text_k: Iterable or float, default 293 :param qext_w: External heat feed-in to the pipes in [W] @@ -1364,7 +1371,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": std_type, "length_km": length_km, "diameter_m": pipe_parameters["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, + "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} _set_multiple_entries(net, "pipe", index, **entries, **kwargs) @@ -1375,7 +1382,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, + loss_coefficient=0, sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ @@ -1402,8 +1409,8 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d :param sections: The number of internal pipe sections. Important for gas and temperature\ calculations, where variables are dependent on pipe length. :type sections: Iterable or int, default 1 - :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] - :type alpha_w_per_m2k: Iterable or float, default 0 + :param u_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] + :type u_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] :type text_k: Iterable or float, default 293 :param qext_w: External heat feed-in to the pipes in [W] @@ -1441,9 +1448,23 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, + "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} + if 'alpha_w_per_m2k' in kwargs: + u_w_per_m2k = alpha_w_per_m2k + + raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.' + ' In the future alpha will be renamed to u.' + ' Please define only one variable for the heat transfer coefficient. ' + 'u will be overwritten by alpha') + + + + if 'std_type' in kwargs: + raise UserWarning('you have defined a std_type, however, using this function you can only ' + 'create a pipe setting specific, individual parameters. If you want to ' + 'create a pipe from net.std_types, please use `create_pipe`') _set_multiple_entries(net, "pipe", index, **entries, **kwargs) if geodata is not None: diff --git a/src/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py index 07136dc08..430b982a5 100644 --- a/src/pandapipes/io/convert_format.py +++ b/src/pandapipes/io/convert_format.py @@ -45,6 +45,9 @@ def _rename_columns(net): else: net['controller'].drop('controller', inplace=True, axis=1) net["controller"].rename(columns={"controller": "object"}, inplace=True) + if "pipe" in net: + if "u_w_per_m2k" not in net["pipe"]: + net["pipe"].rename(columns={"alpha_w_per_m2k": "u_w_per_m2k"}, inplace=True) for comp in [CirculationPumpMass, CirculationPumpPressure]: cp_tbl = comp.table_name() if cp_tbl in net: diff --git a/src/pandapipes/std_types/library/Pipe.csv b/src/pandapipes/std_types/library/Pipe.csv index 800b02ed4..4a5eebda5 100644 --- a/src/pandapipes/std_types/library/Pipe.csv +++ b/src/pandapipes/std_types/library/Pipe.csv @@ -1,221 +1,239 @@ -std_type;nominal_width_mm;outer_diameter_mm;inner_diameter_mm;standard_dimension_ratio;material -80_GGG;80;98.0;86.0;16.33;GGG -100_GGG;100;118.0;105.8;19.34;GGG -125_GGG;125;144.0;131.6;23.23;GGG -150_GGG;150;170.0;157.0;26.15;GGG -200_GGG;200;222.0;208.0;31.71;GGG -250_GGG;250;274.0;259.0;36.53;GGG -300_GGG;300;326.0;310.0;40.75;GGG -350_GGG;350;378.0;361.0;44.47;GGG -400_GGG;400;429.0;411.0;47.67;GGG -500_GGG;500;532.0;512.0;53.2;GGG -600_GGG;600;635.0;613.0;57.73;GGG -20_PE_100_SDR_11;20;20.0;16.2;10.53;PE 100 -25_PE_100_SDR_11;25;25.0;20.4;10.87;PE 100 -32_PE_100_SDR_11;32;32.0;26.2;11.03;PE 100 -40_PE_100_SDR_11;40;40.0;32.6;10.81;PE 100 -50_PE_100_SDR_11;50;50.0;40.8;10.87;PE 100 -63_PE_100_SDR_11;63;63.0;51.4;10.86;PE 100 -75_PE_100_SDR_11;75;75.0;61.4;11.03;PE 100 -90_PE_100_SDR_11;90;90.0;73.6;10.98;PE 100 -90_PE_100_SDR_17;90;90.0;79.2;16.67;PE 100 -110_PE_100_SDR_11;110;110.0;90.0;11.0;PE 100 -110_PE_100_SDR_17;110;110.0;96.8;16.67;PE 100 -125_PE_100_SDR_11;125;125.0;102.2;10.96;PE 100 -125_PE_100_SDR_17;125;125.0;110.2;16.89;PE 100 -140_PE_100_SDR_17;140;140.0;123.4;16.87;PE 100 -160_PE_100_SDR_11;160;160.0;130.8;10.96;PE 100 -160_PE_100_SDR_17;160;160.0;141.0;16.84;PE 100 -180_PE_100_SDR_17;180;180.0;158.6;16.82;PE 100 -180_PE_100_SDR_11;180;180.0;147.2;10.98;PE 100 -200_PE_100_SDR_17;200;200.0;176.2;16.81;PE 100 -225_PE_100_SDR_11;225;225.0;184.0;10.98;PE 100 -225_PE_100_SDR_17;225;225.0;198.2;16.79;PE 100 -250_PE_100_SDR_11;250;250.0;204.6;11.01;PE 100 -250_PE_100_SDR_17;250;250.0;220.4;16.89;PE 100 -280_PE_100_SDR_11;280;280.0;229.2;11.02;PE 100 -280_PE_100_SDR_17;280;280.0;246.8;16.87;PE 100 -315_PE_100_SDR_17;315;315.0;277.6;16.84;PE 100 -315_PE_100_SDR_11;315;315.0;257.8;11.01;PE 100 -355_PE_100_SDR_11;355;355.0;290.6;11.02;PE 100 -355_PE_100_SDR_17;355;355.0;312.8;16.82;PE 100 -400_PE_100_SDR_11;400;400.0;327.4;11.02;PE 100 -400_PE_100_SDR_17;400;400.0;352.6;16.88;PE 100 -450_PE_100_SDR_17;450;450.0;396.6;16.85;PE 100 -450_PE_100_SDR_11;450;450.0;368.0;10.98;PE 100 -500_PE_100_SDR_17;500;500.0;440.6;16.84;PE 100 -560_PE_100_SDR_17;560;560.0;493.6;16.87;PE 100 -630_PE_100_SDR_17;630;630.0;555.2;16.84;PE 100 -710_PE_100_SDR_17;710;710.0;625.8;16.86;PE 100 -800_PE_100_SDR_17;800;800.0;705.2;16.88;PE 100 -900_PE_100_SDR_17;900;900.0;793.4;16.89;PE 100 -20_PE_80_SDR_11;20;20.0;16.2;10.53;PE 80 -25_PE_80_SDR_11;25;25.0;20.4;10.87;PE 80 -32_PE_80_SDR_17.6;32;32.0;28.4;17.78;PE 80 -32_PE_80_SDR_11;32;32.0;26.2;11.03;PE 80 -40_PE_80_SDR_11;40;40.0;32.6;10.81;PE 80 -50_PE_80_SDR_11;50;50.0;40.8;10.87;PE 80 -63_PE_80_SDR_11;63;63.0;51.4;10.86;PE 80 -75_PE_80_SDR_11;75;75.0;61.4;11.03;PE 80 -90_PE_80_SDR_17;90;90.0;79.2;16.67;PE 80 -90_PE_80_SDR_11;90;90.0;73.6;10.98;PE 80 -110_PE_80_SDR_17;110;110.0;96.8;16.67;PE 80 -110_PE_80_SDR_11;110;110.0;90.0;11.0;PE 80 -125_PE_80_SDR_17;125;125.0;110.2;16.89;PE 80 -125_PE_80_SDR_11;125;125.0;102.2;10.96;PE 80 -140_PE_80_SDR_17;140;140.0;123.4;16.87;PE 80 -160_PE_80_SDR_17;160;160.0;141.0;16.84;PE 80 -160_PE_80_SDR_11;160;160.0;130.8;10.96;PE 80 -180_PE_80_SDR_11;180;180.0;147.2;10.98;PE 80 -180_PE_80_SDR_17;180;180.0;158.6;16.82;PE 80 -200_PE_80_SDR_17;200;200.0;176.2;16.81;PE 80 -225_PE_80_SDR_17;225;225.0;198.2;16.79;PE 80 -225_PE_80_SDR_11;225;225.0;184.0;10.98;PE 80 -250_PE_80_SDR_17;250;250.0;220.4;16.89;PE 80 -250_PE_80_SDR_11;250;250.0;204.6;11.01;PE 80 -280_PE_80_SDR_17;280;280.0;246.8;16.87;PE 80 -280_PE_80_SDR_11;280;280.0;229.2;11.02;PE 80 -315_PE_80_SDR_17;315;315.0;277.6;16.84;PE 80 -315_PE_80_SDR_11;315;315.0;257.8;11.01;PE 80 -355_PE_80_SDR_11;355;355.0;290.6;11.02;PE 80 -355_PE_80_SDR_17;355;355.0;312.8;16.82;PE 80 -400_PE_80_SDR_11;400;400.0;327.4;11.02;PE 80 -400_PE_80_SDR_17;400;400.0;352.6;16.88;PE 80 -450_PE_80_SDR_17;450;450.0;396.6;16.85;PE 80 -500_PE_80_SDR_17;500;500.0;440.6;16.84;PE 80 -560_PE_80_SDR_17;560;560.0;493.6;16.87;PE 80 -630_PE_80_SDR_17;630;630.0;555.2;16.84;PE 80 -710_PE_80_SDR_17;710;710.0;625.8;16.86;PE 80 -800_PE_80_SDR_17;800;800.0;705.2;16.88;PE 80 -900_PE_80_SDR_17;900;900.0;793.4;16.89;PE 80 -75_PE-HD_10;75;75.0;61.2;10.87;PE-HD 10 -90_PE-HD_10;90;90.0;73.6;10.98;PE-HD 10 -110_PE-HD_10;110;110.0;90.0;11.0;PE-HD 10 -140_PE-HD_10;140;140.0;114.4;10.94;PE-HD 10 -160_PE-HD_10;160;160.0;130.8;10.96;PE-HD 10 -225_PE-HD_10;225;225.0;184.0;10.98;PE-HD 10 -280_PE-HD_10;280;280.0;229.0;10.98;PE-HD 10 -355_PE-HD_10;355;355.0;290.4;10.99;PE-HD 10 -400_PE-HD_10;400;400.0;327.2;10.99;PE-HD 10 -450_PE-HD_10;450;450.0;368.0;10.98;PE-HD 10 -20_PE-HD_16;20;20.0;14.4;7.14;PE-HD 16 -25_PE-HD_16;25;25.0;18.0;7.14;PE-HD 16 -32_PE-HD_16;32;32.0;23.0;7.11;PE-HD 16 -40_PE-HD_16;40;40.0;28.8;7.14;PE-HD 16 -50_PE-HD_16;50;50.0;36.2;7.25;PE-HD 16 -63_PE-HD_16;63;63.0;45.6;7.24;PE-HD 16 -75_PE-HD_16;75;75.0;54.2;7.21;PE-HD 16 -90_PE-HD_16;90;90.0;65.0;7.2;PE-HD 16 -110PE-HD_16;110;110.0;79.6;7.24;PE-HD 16 -125_PE-HD_16;125;125.0;90.4;7.23;PE-HD 16 -140_PE-HD_16;140;140.0;103.2;7.61;PE-HD 16 -160_PE-HD_16;160;160.0;115.8;7.24;PE-HD 16 -180-PE-HD_16;180;180.0;130.2;7.23;PE-HD 16 -200-PE-HD_16;200;200.0;144.8;7.25;PE-HD 16 -225_PE-HD_16;225;225.0;162.8;7.23;PE-HD 16 -250_PE-HD_16;250;250.0;181.0;7.25;PE-HD 16 -280_PE-HD_16;280;280.0;202.6;7.24;PE-HD 16 -315_PE-HD_16;315;315.0;228.0;7.24;PE-HD 16 -355_PE-HD_16;355;355.0;257.0;7.24;PE-HD 16 -400_PE-HD_16;400;400.0;289.6;7.25;PE-HD 16 -90_PE-HD_6;90;90.0;79.8;17.65;PE-HD 6 -110_PE-HD_6;110;110.0;97.4;17.46;PE-HD 6 -125_PE-HD_6;125;125.0;110.8;17.61;PE-HD 6 -140_PE-HD_6;140;140.0;124.0;17.5;PE-HD 6 -160_PE-HD_6;160;160.0;141.8;17.58;PE-HD 6 -180_PE-HD_6;180;180.0;159.6;17.65;PE-HD 6 -200_PE-HD_6;200;200.0;177.2;17.54;PE-HD 6 -225_PE-HD_6;225;225.0;199.4;17.58;PE-HD 6 -250_PE-HD_6;250;250.0;221.6;17.61;PE-HD 6 -280_PE-HD_6;280;280.0;248.2;17.61;PE-HD 6 -315_PE-HD_6;315;315.0;279.2;17.6;PE-HD 6 -355_PE-HD_6;355;355.0;314.8;17.66;PE-HD 6 -400_PE-HD_6;400;400.0;354.6;17.62;PE-HD 6 -450_PE-HD_6;450;450.0;399.0;17.65;PE-HD 6 -500_PE-HD_6;500;500.0;443.4;17.67;PE-HD 6 -560_PE-HD_6;560;560.0;496.6;17.67;PE-HD 6 -630_PE-HD_6;630;630.0;558.6;17.65;PE-HD 6 -25_PE-Xa_SDR_11;25;32.0;26.2;11.03;PE-Xa -32_PE-Xa_SDR_11;32;40.0;32.6;10.81;PE-Xa -40_PE-Xa_SDR_11;40;50.0;40.8;10.87;PE-Xa -50_PE-Xa_SDR_11;50;63.0;51.4;10.86;PE-Xa -65_PE-Xa_SDR_11;65;75.0;61.4;11.03;PE-Xa -80_PE-Xa_SDR_11;80;90.0;73.6;10.98;PE-Xa -40_PE_80_SDR_17.6;40;40.0;35.4;17.39;PE 80 -50_PE_80_SDR_17.6;50;50.0;44.2;17.24;PE 80 -63_PE_80_SDR_17.6;63;63.0;55.8;17.5;PE 80 -90_PE_80_SDR_17.6;90;90.0;79.8;17.65;PE 80 -110_PE_80_SDR_17.6;110;110.0;97.4;17.46;PE 80 -125_PE_80_SDR_17.6;125;125.0;110.8;17.61;PE 80 -160_PE_80_SDR_17.6;160;160.0;141.8;17.58;PE 80 -180_PE_80_SDR_17.6;180;180.0;159.6;17.65;PE 80 -225_PE_80_SDR_17.6;225;225.0;199.4;17.58;PE 80 -250_PE_80_SDR_17.6;250;250.0;221.6;17.61;PE 80 -280_PE_80_SDR_17.6;280;280.0;248.2;17.61;PE 80 -315_PE_80_SDR_17.6;315;315.0;279.2;17.6;PE 80 -355_PE_80_SDR_17.6;355;355.0;314.8;17.66;PE 80 -400_PE_80_SDR_17.6;400;400.0;354.6;17.62;PE 80 -50_PVC_10;50;63.0;57.0;21.0;PVC -80_PVC_10;80;90.0;81.4;20.93;PVC -100_PVC_10;100;110.0;99.4;20.75;PVC -125_PVC_10;125;140.0;126.6;20.9;PVC -150_PVC_10;150;160.0;144.6;20.78;PVC -200_PVC_10;200;225.0;203.4;20.83;PVC -250_PVC_10;250;280.0;253.2;20.9;PVC -300_PVC_10;300;355.0;321.2;21.01;PVC -350_PVC_10;350;400.0;361.8;20.94;PVC -400_PVC_10;400;450.0;407.0;20.93;PVC -500_PVC_10;500;560.0;506.6;20.97;PVC -600_PVC_10;600;630.0;570.0;21.0;PVC -20_ST;20;25.0;21.0;12.5;ST -20_ST<16;20;26.9;22.3;11.7;ST -25_ST;25;30.0;26.0;15.0;ST -25_ST<16;25;33.7;28.5;12.96;ST -25_ST>16;25;33.7;27.9;11.62;ST -32_ST;32;38.0;33.4;16.52;ST -32_ST<16;32;42.4;37.2;16.31;ST -32_ST>16;32;42.4;36.6;14.62;ST -40_ST;40;48.3;43.7;21.0;ST -40_ST<16;40;48.3;43.1;18.58;ST -50_ST;50;60.3;55.7;26.22;ST -50_ST<16;50;60.3;54.5;20.79;ST -65_ST;65;88.9;83.7;34.19;ST -65_ST<16;65;76.1;70.3;26.24;ST -65_ST>16;65;88.9;82.5;27.78;ST -80_ST;80;88.9;84.3;38.65;ST -80_ST<16;80;88.9;82.5;27.78;ST -80_ST>16;80;88.9;81.7;24.69;ST -100_ST;100;114.3;109.1;43.96;ST -100_ST<16;100;114.3;107.9;35.72;ST -100_ST>16;100;114.3;107.1;31.75;ST -125_ST<16;125;139.7;132.5;38.81;ST -125_ST>16;125;139.7;131.7;34.92;ST -150_ST;150;168.3;162.5;58.03;ST -150_ST<16;150;168.3;160.3;42.08;ST -150_ST>16;150;168.3;159.3;37.4;ST -200_ST;200;219.1;212.7;68.47;ST -200_ST<16;200;219.1;210.1;48.69;ST -200_ST>16;200;219.1;209.1;43.82;ST -250_ST;250;273.0;265.8;75.83;ST -250_ST<16;250;273.0;263.0;54.6;ST -250_ST>16;250;273.0;261.8;48.75;ST -300_ST;300;323.9;315.9;80.97;ST -300_ST<16;300;323.9;312.7;57.84;ST -300_ST>16;300;323.9;311.3;51.41;ST -350_ST;350;355.6;346.6;79.02;ST -350_ST<16;350;355.6;344.4;63.5;ST -400_ST;400;406.4;397.4;90.31;ST -400_ST<16;400;406.4;393.8;64.51;ST -500_ST;500;508.0;496.8;90.71;ST -500_ST<16;500;508.0;495.4;80.63;ST -600_ST;600;610.0;598.8;108.93;ST -600_ST<16;600;610.0;597.4;96.83;ST -700_ST<16;700;711.0;696.8;100.14;ST -800_ST<16;800;813.0;797.0;101.62;ST -900_ST<16;900;914.0;894.0;91.4;ST -1000_ST<16;1000;1016.0;996.0;101.6;ST -1200_ST<16;1200;1220.0;1198.0;110.91;ST -1400_ST<16;1400;1420.0;1398.0;129.09;ST -1600_ST<16;1600;1620.0;1588.0;101.25;ST -1800_ST<16;1800;1820.0;1785.0;104.0;ST -2000_ST<16;2000;2020.0;1980.0;101.0;ST +std_type;nominal_width_mm;outer_diameter_mm;inner_diameter_mm;standard_dimension_ratio;material;u_w_per_m2k +80_GGG;80;98;86;16.33;GGG;0 +100_GGG;100;118;105.8;19.34;GGG;0 +125_GGG;125;144;131.6;23.23;GGG;0 +150_GGG;150;170;157;26.15;GGG;0 +200_GGG;200;222;208;31.71;GGG;0 +250_GGG;250;274;259;36.53;GGG;0 +300_GGG;300;326;310;40.75;GGG;0 +350_GGG;350;378;361;44.47;GGG;0 +400_GGG;400;429;411;47.67;GGG;0 +500_GGG;500;532;512;53.2;GGG;0 +600_GGG;600;635;613;57.73;GGG;0 +20_PE_100_SDR_11;20;20;16.2;10.53;PE 100;0 +25_PE_100_SDR_11;25;25;20.4;10.87;PE 100;0 +32_PE_100_SDR_11;32;32;26.2;11.03;PE 100;0 +40_PE_100_SDR_11;40;40;32.6;10.81;PE 100;0 +50_PE_100_SDR_11;50;50;40.8;10.87;PE 100;0 +63_PE_100_SDR_11;63;63;51.4;10.86;PE 100;0 +75_PE_100_SDR_11;75;75;61.4;11.03;PE 100;0 +90_PE_100_SDR_11;90;90;73.6;10.98;PE 100;0 +90_PE_100_SDR_17;90;90;79.2;16.67;PE 100;0 +110_PE_100_SDR_11;110;110;90;11;PE 100;0 +110_PE_100_SDR_17;110;110;96.8;16.67;PE 100;0 +125_PE_100_SDR_11;125;125;102.2;10.96;PE 100;0 +125_PE_100_SDR_17;125;125;110.2;16.89;PE 100;0 +140_PE_100_SDR_17;140;140;123.4;16.87;PE 100;0 +160_PE_100_SDR_11;160;160;130.8;10.96;PE 100;0 +160_PE_100_SDR_17;160;160;141;16.84;PE 100;0 +180_PE_100_SDR_17;180;180;158.6;16.82;PE 100;0 +180_PE_100_SDR_11;180;180;147.2;10.98;PE 100;0 +200_PE_100_SDR_17;200;200;176.2;16.81;PE 100;0 +225_PE_100_SDR_11;225;225;184;10.98;PE 100;0 +225_PE_100_SDR_17;225;225;198.2;16.79;PE 100;0 +250_PE_100_SDR_11;250;250;204.6;11.01;PE 100;0 +250_PE_100_SDR_17;250;250;220.4;16.89;PE 100;0 +280_PE_100_SDR_11;280;280;229.2;11.02;PE 100;0 +280_PE_100_SDR_17;280;280;246.8;16.87;PE 100;0 +315_PE_100_SDR_17;315;315;277.6;16.84;PE 100;0 +315_PE_100_SDR_11;315;315;257.8;11.01;PE 100;0 +355_PE_100_SDR_11;355;355;290.6;11.02;PE 100;0 +355_PE_100_SDR_17;355;355;312.8;16.82;PE 100;0 +400_PE_100_SDR_11;400;400;327.4;11.02;PE 100;0 +400_PE_100_SDR_17;400;400;352.6;16.88;PE 100;0 +450_PE_100_SDR_17;450;450;396.6;16.85;PE 100;0 +450_PE_100_SDR_11;450;450;368;10.98;PE 100;0 +500_PE_100_SDR_17;500;500;440.6;16.84;PE 100;0 +560_PE_100_SDR_17;560;560;493.6;16.87;PE 100;0 +630_PE_100_SDR_17;630;630;555.2;16.84;PE 100;0 +710_PE_100_SDR_17;710;710;625.8;16.86;PE 100;0 +800_PE_100_SDR_17;800;800;705.2;16.88;PE 100;0 +900_PE_100_SDR_17;900;900;793.4;16.89;PE 100;0 +20_PE_80_SDR_11;20;20;16.2;10.53;PE 80;0 +25_PE_80_SDR_11;25;25;20.4;10.87;PE 80;0 +32_PE_80_SDR_17.6;32;32;28.4;17.78;PE 80;0 +32_PE_80_SDR_11;32;32;26.2;11.03;PE 80;0 +40_PE_80_SDR_11;40;40;32.6;10.81;PE 80;0 +50_PE_80_SDR_11;50;50;40.8;10.87;PE 80;0 +63_PE_80_SDR_11;63;63;51.4;10.86;PE 80;0 +75_PE_80_SDR_11;75;75;61.4;11.03;PE 80;0 +90_PE_80_SDR_17;90;90;79.2;16.67;PE 80;0 +90_PE_80_SDR_11;90;90;73.6;10.98;PE 80;0 +110_PE_80_SDR_17;110;110;96.8;16.67;PE 80;0 +110_PE_80_SDR_11;110;110;90;11;PE 80;0 +125_PE_80_SDR_17;125;125;110.2;16.89;PE 80;0 +125_PE_80_SDR_11;125;125;102.2;10.96;PE 80;0 +140_PE_80_SDR_17;140;140;123.4;16.87;PE 80;0 +160_PE_80_SDR_17;160;160;141;16.84;PE 80;0 +160_PE_80_SDR_11;160;160;130.8;10.96;PE 80;0 +180_PE_80_SDR_11;180;180;147.2;10.98;PE 80;0 +180_PE_80_SDR_17;180;180;158.6;16.82;PE 80;0 +200_PE_80_SDR_17;200;200;176.2;16.81;PE 80;0 +225_PE_80_SDR_17;225;225;198.2;16.79;PE 80;0 +225_PE_80_SDR_11;225;225;184;10.98;PE 80;0 +250_PE_80_SDR_17;250;250;220.4;16.89;PE 80;0 +250_PE_80_SDR_11;250;250;204.6;11.01;PE 80;0 +280_PE_80_SDR_17;280;280;246.8;16.87;PE 80;0 +280_PE_80_SDR_11;280;280;229.2;11.02;PE 80;0 +315_PE_80_SDR_17;315;315;277.6;16.84;PE 80;0 +315_PE_80_SDR_11;315;315;257.8;11.01;PE 80;0 +355_PE_80_SDR_11;355;355;290.6;11.02;PE 80;0 +355_PE_80_SDR_17;355;355;312.8;16.82;PE 80;0 +400_PE_80_SDR_11;400;400;327.4;11.02;PE 80;0 +400_PE_80_SDR_17;400;400;352.6;16.88;PE 80;0 +450_PE_80_SDR_17;450;450;396.6;16.85;PE 80;0 +500_PE_80_SDR_17;500;500;440.6;16.84;PE 80;0 +560_PE_80_SDR_17;560;560;493.6;16.87;PE 80;0 +630_PE_80_SDR_17;630;630;555.2;16.84;PE 80;0 +710_PE_80_SDR_17;710;710;625.8;16.86;PE 80;0 +800_PE_80_SDR_17;800;800;705.2;16.88;PE 80;0 +900_PE_80_SDR_17;900;900;793.4;16.89;PE 80;0 +75_PE-HD_10;75;75;61.2;10.87;PE-HD 10;0 +90_PE-HD_10;90;90;73.6;10.98;PE-HD 10;0 +110_PE-HD_10;110;110;90;11;PE-HD 10;0 +140_PE-HD_10;140;140;114.4;10.94;PE-HD 10;0 +160_PE-HD_10;160;160;130.8;10.96;PE-HD 10;0 +225_PE-HD_10;225;225;184;10.98;PE-HD 10;0 +280_PE-HD_10;280;280;229;10.98;PE-HD 10;0 +355_PE-HD_10;355;355;290.4;10.99;PE-HD 10;0 +400_PE-HD_10;400;400;327.2;10.99;PE-HD 10;0 +450_PE-HD_10;450;450;368;10.98;PE-HD 10;0 +20_PE-HD_16;20;20;14.4;7.14;PE-HD 16;0 +25_PE-HD_16;25;25;18;7.14;PE-HD 16;0 +32_PE-HD_16;32;32;23;7.11;PE-HD 16;0 +40_PE-HD_16;40;40;28.8;7.14;PE-HD 16;0 +50_PE-HD_16;50;50;36.2;7.25;PE-HD 16;0 +63_PE-HD_16;63;63;45.6;7.24;PE-HD 16;0 +75_PE-HD_16;75;75;54.2;7.21;PE-HD 16;0 +90_PE-HD_16;90;90;65;7.2;PE-HD 16;0 +110PE-HD_16;110;110;79.6;7.24;PE-HD 16;0 +125_PE-HD_16;125;125;90.4;7.23;PE-HD 16;0 +140_PE-HD_16;140;140;103.2;7.61;PE-HD 16;0 +160_PE-HD_16;160;160;115.8;7.24;PE-HD 16;0 +180-PE-HD_16;180;180;130.2;7.23;PE-HD 16;0 +200-PE-HD_16;200;200;144.8;7.25;PE-HD 16;0 +225_PE-HD_16;225;225;162.8;7.23;PE-HD 16;0 +250_PE-HD_16;250;250;181;7.25;PE-HD 16;0 +280_PE-HD_16;280;280;202.6;7.24;PE-HD 16;0 +315_PE-HD_16;315;315;228;7.24;PE-HD 16;0 +355_PE-HD_16;355;355;257;7.24;PE-HD 16;0 +400_PE-HD_16;400;400;289.6;7.25;PE-HD 16;0 +90_PE-HD_6;90;90;79.8;17.65;PE-HD 6;0 +110_PE-HD_6;110;110;97.4;17.46;PE-HD 6;0 +125_PE-HD_6;125;125;110.8;17.61;PE-HD 6;0 +140_PE-HD_6;140;140;124;17.5;PE-HD 6;0 +160_PE-HD_6;160;160;141.8;17.58;PE-HD 6;0 +180_PE-HD_6;180;180;159.6;17.65;PE-HD 6;0 +200_PE-HD_6;200;200;177.2;17.54;PE-HD 6;0 +225_PE-HD_6;225;225;199.4;17.58;PE-HD 6;0 +250_PE-HD_6;250;250;221.6;17.61;PE-HD 6;0 +280_PE-HD_6;280;280;248.2;17.61;PE-HD 6;0 +315_PE-HD_6;315;315;279.2;17.6;PE-HD 6;0 +355_PE-HD_6;355;355;314.8;17.66;PE-HD 6;0 +400_PE-HD_6;400;400;354.6;17.62;PE-HD 6;0 +450_PE-HD_6;450;450;399;17.65;PE-HD 6;0 +500_PE-HD_6;500;500;443.4;17.67;PE-HD 6;0 +560_PE-HD_6;560;560;496.6;17.67;PE-HD 6;0 +630_PE-HD_6;630;630;558.6;17.65;PE-HD 6;0 +25_PE-Xa_SDR_11;25;32;26.2;11.03;PE-Xa;0 +32_PE-Xa_SDR_11;32;40;32.6;10.81;PE-Xa;0 +40_PE-Xa_SDR_11;40;50;40.8;10.87;PE-Xa;0 +50_PE-Xa_SDR_11;50;63;51.4;10.86;PE-Xa;0 +65_PE-Xa_SDR_11;65;75;61.4;11.03;PE-Xa;0 +80_PE-Xa_SDR_11;80;90;73.6;10.98;PE-Xa;0 +40_PE_80_SDR_17.6;40;40;35.4;17.39;PE 80;0 +50_PE_80_SDR_17.6;50;50;44.2;17.24;PE 80;0 +63_PE_80_SDR_17.6;63;63;55.8;17.5;PE 80;0 +90_PE_80_SDR_17.6;90;90;79.8;17.65;PE 80;0 +110_PE_80_SDR_17.6;110;110;97.4;17.46;PE 80;0 +125_PE_80_SDR_17.6;125;125;110.8;17.61;PE 80;0 +160_PE_80_SDR_17.6;160;160;141.8;17.58;PE 80;0 +180_PE_80_SDR_17.6;180;180;159.6;17.65;PE 80;0 +225_PE_80_SDR_17.6;225;225;199.4;17.58;PE 80;0 +250_PE_80_SDR_17.6;250;250;221.6;17.61;PE 80;0 +280_PE_80_SDR_17.6;280;280;248.2;17.61;PE 80;0 +315_PE_80_SDR_17.6;315;315;279.2;17.6;PE 80;0 +355_PE_80_SDR_17.6;355;355;314.8;17.66;PE 80;0 +400_PE_80_SDR_17.6;400;400;354.6;17.62;PE 80;0 +50_PVC_10;50;63;57;21;PVC;0 +80_PVC_10;80;90;81.4;20.93;PVC;0 +100_PVC_10;100;110;99.4;20.75;PVC;0 +125_PVC_10;125;140;126.6;20.9;PVC;0 +150_PVC_10;150;160;144.6;20.78;PVC;0 +200_PVC_10;200;225;203.4;20.83;PVC;0 +250_PVC_10;250;280;253.2;20.9;PVC;0 +300_PVC_10;300;355;321.2;21.01;PVC;0 +350_PVC_10;350;400;361.8;20.94;PVC;0 +400_PVC_10;400;450;407;20.93;PVC;0 +500_PVC_10;500;560;506.6;20.97;PVC;0 +600_PVC_10;600;630;570;21;PVC;0 +20_ST;20;25;21;12.5;ST;0 +20_ST<16;20;26.9;22.3;11.7;ST;0 +25_ST;25;30;26;15;ST;0 +25_ST<16;25;33.7;28.5;12.96;ST;0 +25_ST>16;25;33.7;27.9;11.62;ST;0 +32_ST;32;38;33.4;16.52;ST;0 +32_ST<16;32;42.4;37.2;16.31;ST;0 +32_ST>16;32;42.4;36.6;14.62;ST;0 +40_ST;40;48.3;43.7;21;ST;0 +40_ST<16;40;48.3;43.1;18.58;ST;0 +50_ST;50;60.3;55.7;26.22;ST;0 +50_ST<16;50;60.3;54.5;20.79;ST;0 +65_ST;65;88.9;83.7;34.19;ST;0 +65_ST<16;65;76.1;70.3;26.24;ST;0 +65_ST>16;65;88.9;82.5;27.78;ST;0 +80_ST;80;88.9;84.3;38.65;ST;0 +80_ST<16;80;88.9;82.5;27.78;ST;0 +80_ST>16;80;88.9;81.7;24.69;ST;0 +100_ST;100;114.3;109.1;43.96;ST;0 +100_ST<16;100;114.3;107.9;35.72;ST;0 +100_ST>16;100;114.3;107.1;31.75;ST;0 +125_ST<16;125;139.7;132.5;38.81;ST;0 +125_ST>16;125;139.7;131.7;34.92;ST;0 +150_ST;150;168.3;162.5;58.03;ST;0 +150_ST<16;150;168.3;160.3;42.08;ST;0 +150_ST>16;150;168.3;159.3;37.4;ST;0 +200_ST;200;219.1;212.7;68.47;ST;0 +200_ST<16;200;219.1;210.1;48.69;ST;0 +200_ST>16;200;219.1;209.1;43.82;ST;0 +250_ST;250;273;265.8;75.83;ST;0 +250_ST<16;250;273;263;54.6;ST;0 +250_ST>16;250;273;261.8;48.75;ST;0 +300_ST;300;323.9;315.9;80.97;ST;0 +300_ST<16;300;323.9;312.7;57.84;ST;0 +300_ST>16;300;323.9;311.3;51.41;ST;0 +350_ST;350;355.6;346.6;79.02;ST;0 +350_ST<16;350;355.6;344.4;63.5;ST;0 +400_ST;400;406.4;397.4;90.31;ST;0 +400_ST<16;400;406.4;393.8;64.51;ST;0 +500_ST;500;508;496.8;90.71;ST;0 +500_ST<16;500;508;495.4;80.63;ST;0 +600_ST;600;610;598.8;108.93;ST;0 +600_ST<16;600;610;597.4;96.83;ST;0 +700_ST<16;700;711;696.8;100.14;ST;0 +800_ST<16;800;813;797;101.62;ST;0 +900_ST<16;900;914;894;91.4;ST;0 +1000_ST<16;1000;1016;996;101.6;ST;0 +1200_ST<16;1200;1220;1198;110.91;ST;0 +1400_ST<16;1400;1420;1398;129.09;ST;0 +1600_ST<16;1600;1620;1588;101.25;ST;0 +1800_ST<16;1800;1820;1785;104;ST;0 +2000_ST<16;2000;2020;1980;101;ST;0 +25/91 PLUS;20;94;25;11.36;PEXa;0.099 +32/91 PLUS;25;94;32;12.8;PEXa;0.121 +40/111 PLUS;32;114;40;14.29;PEXa;0.124 +50/111;40;114;47.6;13.22;PEXa;0.147 +50/126 PLUS;40;129;47.6;13.22;PEXa;0.13 +63/126;50;129;58.5;14.63;PEXa;0.162 +63/142 PLUS;50;145;58.5;14.63;PEXa;0.142 +75/142;65;145;69.5;15.11;PEXa;0.173 +75/162 PLUS;65;165;69.5;15.11;PEXa;0.148 +90/162;80;165;84;14;PEXa;0.187 +90/182 PLUS;80;185;84;14;PEXa;0.161 +110/182 PLUS;100;185;101;15.54;PEXa;0.206 +110/202 PLUS;100;205;101;15.54;PEXa;0.178 +125/202 PLUS;125;205;116;17.06;PEXa;0.217 +125/225 PLUS;125;228;116;17.06;PEXa;0.185 +140/202;125;205;127;17.89;PEXa;0.255 +140/225 PLUS;125;228;127;17.89;PEXa;0.212 +160/225;150;228;144;19.2;PEXa;0.264 diff --git a/src/pandapipes/test/api/release_cycle/release_control_test_network.py b/src/pandapipes/test/api/release_cycle/release_control_test_network.py index c1ed060de..c8540b280 100644 --- a/src/pandapipes/test/api/release_cycle/release_control_test_network.py +++ b/src/pandapipes/test/api/release_cycle/release_control_test_network.py @@ -45,28 +45,28 @@ def release_control_test_network(max_iter_hyd, save=False): # pipes pp.create_pipe_from_parameters( net, from_junction=0, to_junction=8, length_km=3, diameter_m=0.01, k_mm=1, - loss_coefficient=0, sections=10, alpha_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", + loss_coefficient=0, sections=10, u_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", index=None, geodata=None, in_service=True, type="pipe") pp.create_pipe_from_parameters( - net, 9, 2, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 9, 2, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 1") pp.create_pipe_from_parameters( - net, 2, 12, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, alpha_w_per_m2k=20, + net, 2, 12, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, u_w_per_m2k=20, name="Pipe 2") pp.create_pipe_from_parameters( - net, 4, 12, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, alpha_w_per_m2k=2, + net, 4, 12, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, u_w_per_m2k=2, name="Pipe 3") pp.create_pipe_from_parameters( - net, 5, 3, length_km=1, diameter_m=0.09, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 5, 3, length_km=1, diameter_m=0.09, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 4") pp.create_pipe_from_parameters( - net, 4, 11, length_km=2.5, diameter_m=0.08, k_mm=.1, sections=10, alpha_w_per_m2k=15, + net, 4, 11, length_km=2.5, diameter_m=0.08, k_mm=.1, sections=10, u_w_per_m2k=15, name="Pipe 5") pp.create_pipe_from_parameters( - net, 7, 6, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, alpha_w_per_m2k=2.5, + net, 7, 6, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, u_w_per_m2k=2.5, name="Pipe 6") pp.create_pipe_from_parameters( - net, 1, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1, + net, 1, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, u_w_per_m2k=1, name="Pipe 7") # external grids @@ -161,28 +161,28 @@ def release_control_test_network_water(max_iter_hyd, save=False): # pipes pp.create_pipe_from_parameters( net, from_junction=0, to_junction=8, length_km=3, diameter_m=0.01, k_mm=1, - loss_coefficient=0, sections=10, alpha_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", + loss_coefficient=0, sections=10, u_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", index=None, geodata=None, in_service=True, type="pipe") pp.create_pipe_from_parameters( - net, 9, 2, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 9, 2, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 1") pp.create_pipe_from_parameters( - net, 2, 12, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, alpha_w_per_m2k=20, + net, 2, 12, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, u_w_per_m2k=20, name="Pipe 2") pp.create_pipe_from_parameters( - net, 4, 12, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, alpha_w_per_m2k=2, + net, 4, 12, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, u_w_per_m2k=2, name="Pipe 3") pp.create_pipe_from_parameters( - net, 5, 3, length_km=1, diameter_m=0.09, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 5, 3, length_km=1, diameter_m=0.09, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 4") pp.create_pipe_from_parameters( - net, 4, 11, length_km=2.5, diameter_m=0.08, k_mm=.1, sections=10, alpha_w_per_m2k=15, + net, 4, 11, length_km=2.5, diameter_m=0.08, k_mm=.1, sections=10, u_w_per_m2k=15, name="Pipe 5") pp.create_pipe_from_parameters( - net, 7, 13, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, alpha_w_per_m2k=2.5, + net, 7, 13, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, u_w_per_m2k=2.5, name="Pipe 6") pp.create_pipe_from_parameters( - net, 1, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1, + net, 1, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, u_w_per_m2k=1, name="Pipe 7") # external grids @@ -271,29 +271,29 @@ def release_control_test_network_gas(max_iter_hyd, save=False): # pipes pp.create_pipe_from_parameters( net, from_junction=0, to_junction=1, length_km=3, diameter_m=0.1, k_mm=1, - loss_coefficient=0, sections=10, alpha_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", + loss_coefficient=0, sections=10, u_w_per_m2k=10, text_k=293, qext_w=0., name="Pipe 0", index=None, geodata=None, in_service=True, type="pipe") pp.create_pipe_from_parameters( - net, 2, 3, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 2, 3, length_km=6, diameter_m=0.075, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 1") pp.create_pipe_from_parameters( - net, 3, 4, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, alpha_w_per_m2k=20, + net, 3, 4, length_km=5, diameter_m=0.06, k_mm=.1, sections=10, u_w_per_m2k=20, name="Pipe 2") pp.create_pipe_from_parameters( - net, 4, 5, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, alpha_w_per_m2k=2, + net, 4, 5, length_km=0.1, diameter_m=0.07, k_mm=.1, sections=10, u_w_per_m2k=2, name="Pipe 3") pp.create_pipe_from_parameters( - net, 5, 6, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, alpha_w_per_m2k=2.5, + net, 5, 6, length_km=4.5, diameter_m=0.085, k_mm=.1, sections=10, u_w_per_m2k=2.5, name="Pipe 4") pp.create_pipe_from_parameters( - net, 8, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1, + net, 8, 7, length_km=4, diameter_m=0.03, k_mm=.1, sections=10, u_w_per_m2k=1, name="Pipe 5") pp.create_pipe_from_parameters( - net, 9, 10, length_km=1, diameter_m=0.03, k_mm=.1, sections=10, alpha_w_per_m2k=1, + net, 9, 10, length_km=1, diameter_m=0.03, k_mm=.1, sections=10, u_w_per_m2k=1, name="Pipe 6") pp.create_pipe_from_parameters( - net, 11, 12, length_km=1.5, diameter_m=0.09, k_mm=.1, sections=10, alpha_w_per_m2k=3, + net, 11, 12, length_km=1.5, diameter_m=0.09, k_mm=.1, sections=10, u_w_per_m2k=3, name="Pipe 7") # external grids diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index a78edc713..8214b2178 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -90,7 +90,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.create_ext_grid(net, j0, 5, 645, type="pt") pandapipes.create_sink(net, j1, 1) pandapipes.create_pipe_from_parameters(net, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 3 if use_numba else 3 @@ -112,7 +112,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.create_sink(net2, j1, 1) pandapipes.create_pipe_from_parameters(net2, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 12 if use_numba else 12 @@ -148,11 +148,11 @@ def test_t_type_tee(use_numba): pandapipes.create_ext_grid(net, j2, 5, 310, type="t") pandapipes.create_pipe_from_parameters(net, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -177,11 +177,11 @@ def test_t_type_tee(use_numba): pandapipes.create_sink(net2, j3, 1) pandapipes.create_pipe_from_parameters(net2, j0, j1, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j3, 2.5, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, @@ -218,13 +218,13 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.create_ext_grid(net, j0, 5, 645, type="t") pandapipes.create_pipe_from_parameters(net, j0, j2, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 4 if use_numba else 4 max_iter_therm = 5 if use_numba else 5 @@ -249,13 +249,13 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.create_sink(net2, j4, 1) pandapipes.create_pipe_from_parameters(net2, j0, j2, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j2, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, @@ -292,13 +292,13 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.create_ext_grid(net, j4, 5, 382.485897, type="t") pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 6 if use_numba else 6 @@ -323,13 +323,13 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.create_sink(net2, j4, 1) pandapipes.create_pipe_from_parameters(net2, j0, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j2, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j2, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j2, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, @@ -366,13 +366,13 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.create_ext_grid(net, j4, 5, 382.485897, type="t") pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j1, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -399,13 +399,13 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.create_sink(net2, j4, 1) pandapipes.create_pipe_from_parameters(net2, j0, j1, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j2, j1, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j3, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net2, j1, j4, 2.5, diameter_m=d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net2, "water", overwrite=True) pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, diff --git a/src/pandapipes/test/api/test_components/test_flow_control.py b/src/pandapipes/test/api/test_components/test_flow_control.py index 026532d59..ab4e03dc4 100644 --- a/src/pandapipes/test/api/test_components/test_flow_control.py +++ b/src/pandapipes/test/api/test_components/test_flow_control.py @@ -12,7 +12,7 @@ def test_flow_control_simple_heat(use_numba): j1, j2, j3, j4, j5, j6, j7, j8 = j p12, p25, p48, p74 = pandapipes.create_pipes_from_parameters( - net, [j1, j2, j4, j7], [j2, j5, j8, j4], 0.2, 0.1, k_mm=0.1, alpha_w_per_m2k=20., + net, [j1, j2, j4, j7], [j2, j5, j8, j4], 0.2, 0.1, k_mm=0.1, u_w_per_m2k=20., text_k=280) pandapipes.create_heat_exchanger(net, j3, j4, 0.1, 50000, 1) diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 491a117a5..db27936fa 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -21,7 +21,7 @@ def simple_heat_net(): system=["flow"] * 3 + ["return"] * 3) pandapipes.create_pipes_from_parameters( net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, - system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 + system=["flow"] * 2 + ["return"] * 2, u_w_per_m2k=10, text_k=273.15 ) pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 400, type='pt') return net diff --git a/src/pandapipes/test/api/test_create.py b/src/pandapipes/test/api/test_create.py index 50fe21f6b..3db407902 100644 --- a/src/pandapipes/test/api/test_create.py +++ b/src/pandapipes/test/api/test_create.py @@ -315,7 +315,7 @@ def test_create_pipes_from_parameters(create_empty_net): p = pandapipes.create_pipes_from_parameters( net, [j1, j1], [j2, j2], length_km=5, diameter_m=0.8, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01) assert len(net.pipe) == 2 assert len(net.pipe_geodata) == 2 @@ -335,8 +335,8 @@ def test_create_pipes_from_parameters(create_empty_net): assert net.pipe.at[p[1], "diameter_m"] == 0.8 assert net.pipe.at[p[0], "sections"] == 2 assert net.pipe.at[p[1], "sections"] == 2 - assert net.pipe.at[p[0], "alpha_w_per_m2k"] == 0.1 - assert net.pipe.at[p[1], "alpha_w_per_m2k"] == 0.1 + assert net.pipe.at[p[0], "u_w_per_m2k"] == 0.1 + assert net.pipe.at[p[1], "u_w_per_m2k"] == 0.1 assert net.pipe.at[p[0], "text_k"] == 273 assert net.pipe.at[p[1], "text_k"] == 273 assert net.pipe.at[p[0], "qext_w"] == 0.01 @@ -351,7 +351,7 @@ def test_create_pipes_from_parameters(create_empty_net): in_service=[True, False], geodata=[[(10, 10), (20, 20)], [(100, 10), (200, 20)]], name=["p1", "p2"], k_mm=[0.01, 0.02], loss_coefficient=[0.3, 0.5], sections=[1, 2], - alpha_w_per_m2k=[0.1, 0.2], text_k=[273, 274], qext_w=[0.01, 0.02]) + u_w_per_m2k=[0.1, 0.2], text_k=[273, 274], qext_w=[0.01, 0.02]) assert len(net.pipe) == 2 assert len(net.pipe_geodata) == 2 @@ -369,8 +369,8 @@ def test_create_pipes_from_parameters(create_empty_net): assert net.pipe.at[p[1], "k_mm"] == 0.02 assert net.pipe.at[p[0], "loss_coefficient"] == 0.3 assert net.pipe.at[p[1], "loss_coefficient"] == 0.5 - assert net.pipe.at[p[0], "alpha_w_per_m2k"] == 0.1 - assert net.pipe.at[p[1], "alpha_w_per_m2k"] == 0.2 + assert net.pipe.at[p[0], "u_w_per_m2k"] == 0.1 + assert net.pipe.at[p[1], "u_w_per_m2k"] == 0.2 assert net.pipe.at[p[0], "sections"] == 1 assert net.pipe.at[p[1], "sections"] == 2 assert net.pipe.at[p[0], "text_k"] == 273 @@ -389,17 +389,17 @@ def test_create_pipes_from_parameters_raise_except(create_empty_net): pandapipes.create_pipes_from_parameters( net, [1, 3], [4, 5], length_km=5, diameter_m=0.8, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01) pandapipes.create_pipes_from_parameters( net, [j1, j1], [j2, j3], length_km=5, diameter_m=0.8, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) with pytest.raises(UserWarning, match=r"with indexes \[0 1\] already exist"): pandapipes.create_pipes_from_parameters( net, [j1, j1], [j2, j3], length_km=5, diameter_m=0.8, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) def test_create_pipes(create_empty_net): @@ -433,7 +433,7 @@ def test_create_pipes(create_empty_net): p = pandapipes.create_pipes( net, [j1, j1], [j2, j2], std_type="80_GGG", length_km=5, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01) assert len(net.pipe) == 2 assert len(net.pipe_geodata) == 2 @@ -455,8 +455,8 @@ def test_create_pipes(create_empty_net): assert net.pipe.at[p[1], "diameter_m"] == 0.086 assert net.pipe.at[p[0], "sections"] == 2 assert net.pipe.at[p[1], "sections"] == 2 - assert net.pipe.at[p[0], "alpha_w_per_m2k"] == 0.1 - assert net.pipe.at[p[1], "alpha_w_per_m2k"] == 0.1 + assert net.pipe.at[p[0], "u_w_per_m2k"] == 0.1 + assert net.pipe.at[p[1], "u_w_per_m2k"] == 0.1 assert net.pipe.at[p[0], "text_k"] == 273 assert net.pipe.at[p[1], "text_k"] == 273 assert net.pipe.at[p[0], "qext_w"] == 0.01 @@ -470,7 +470,7 @@ def test_create_pipes(create_empty_net): net, [j1, j1], [j2, j2], std_type="80_GGG", length_km=[1, 5], in_service=[True, False], geodata=[[(10, 10), (20, 20)], [(100, 10), (200, 20)]], name=["p1", "p2"], k_mm=[0.01, 0.02], loss_coefficient=[0.3, 0.5], sections=[1, 2], - alpha_w_per_m2k=[0.1, 0.2], text_k=[273, 274], qext_w=[0.01, 0.02]) + u_w_per_m2k=[0.1, 0.2], text_k=[273, 274], qext_w=[0.01, 0.02]) assert len(net.pipe) == 2 assert len(net.pipe_geodata) == 2 @@ -490,8 +490,8 @@ def test_create_pipes(create_empty_net): assert net.pipe.at[p[1], "k_mm"] == 0.02 assert net.pipe.at[p[0], "loss_coefficient"] == 0.3 assert net.pipe.at[p[1], "loss_coefficient"] == 0.5 - assert net.pipe.at[p[0], "alpha_w_per_m2k"] == 0.1 - assert net.pipe.at[p[1], "alpha_w_per_m2k"] == 0.2 + assert net.pipe.at[p[0], "u_w_per_m2k"] == 0.1 + assert net.pipe.at[p[1], "u_w_per_m2k"] == 0.2 assert net.pipe.at[p[0], "sections"] == 1 assert net.pipe.at[p[1], "sections"] == 2 assert net.pipe.at[p[0], "text_k"] == 273 @@ -510,17 +510,17 @@ def test_create_pipes_raise_except(create_empty_net): pandapipes.create_pipes( net, [1, 3], [4, 5], std_type="80_GGG", length_km=5, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01) pandapipes.create_pipes( net, [j1, j1], [j2, j3], std_type="80_GGG", length_km=5, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) with pytest.raises(UserWarning, match=r"with indexes \[0 1\] already exist"): pandapipes.create_pipes( net, [j1, j1], [j2, j3], std_type="80_GGG", length_km=5, in_service=False, geodata=[(10, 10), (20, 20)], name="test", k_mm=0.01, loss_coefficient=0.3, sections=2, - alpha_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) + u_w_per_m2k=0.1, text_k=273, qext_w=0.01, index=[0, 1]) def test_create_valves(create_empty_net): diff --git a/src/pandapipes/test/api/test_network_tables.py b/src/pandapipes/test/api/test_network_tables.py index 8ee1510bf..04ff9c8e9 100644 --- a/src/pandapipes/test/api/test_network_tables.py +++ b/src/pandapipes/test/api/test_network_tables.py @@ -24,7 +24,7 @@ def test_default_input_tables(): pipe_input = list(copy.deepcopy(net.pipe.columns)) pandapipes.create_pipe_from_parameters(net, 0, 1, 6, diameter_m=0.2, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pipe_input_create = list(net.pipe.columns) assert pipe_input == pipe_input_create, "Input does not equal Table in create-function" diff --git a/src/pandapipes/test/api/test_std_types.py b/src/pandapipes/test/api/test_std_types.py index b65da82d9..a912bcb98 100644 --- a/src/pandapipes/test/api/test_std_types.py +++ b/src/pandapipes/test/api/test_std_types.py @@ -305,10 +305,11 @@ def test_available_std_types(): do = 99.5 di = 87.5 rat = 16.33 + u = 10 mat = "GGG" typdata = {"standard_dimension_ratio": rat, "material": mat, "inner_diameter_mm": di, - "outer_diameter_mm": do, "nominal_width_mm": w} + "outer_diameter_mm": do, "nominal_width_mm": w, "u_w_per_m2k":u} typdatas = {"typ1": typdata, "typ2": typdata} pandapipes.create_std_types(net, component="pipe", type_dict=typdatas) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 29ba322fe..32a0d66e3 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -40,13 +40,13 @@ def create_test_net(): pandapipes.create_ext_grid(net, j1, 1, 285.15, type="pt") - pandapipes.create_pipe_from_parameters(net, j1, j2, 0.1, 0.1, sections=1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j3, 0.1, 0.1, sections=2, alpha_w_per_m2k=5, + pandapipes.create_pipe_from_parameters(net, j1, j2, 0.1, 0.1, sections=1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j2, j3, 0.1, 0.1, sections=2, u_w_per_m2k=5, in_service=False) - pandapipes.create_pipe_from_parameters(net, j4, j6, 0.1, 0.1, sections=2, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j6, j7, 0.1, 0.1, sections=1, alpha_w_per_m2k=5, + pandapipes.create_pipe_from_parameters(net, j4, j6, 0.1, 0.1, sections=2, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j6, j7, 0.1, 0.1, sections=1, u_w_per_m2k=5, in_service=False) - pandapipes.create_pipe_from_parameters(net, j1, j5, 0.1, 0.1, sections=2, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j5, 0.1, 0.1, sections=2, u_w_per_m2k=5) pandapipes.create_valve(net, j1, j4, 0.1) pandapipes.create_valve(net, j4, j5, 0.1, opened=False) @@ -80,17 +80,17 @@ def complex_heat_connectivity_grid(): pandapipes.create_ext_grid(net, j7, 1, 320.15, type="t", index=2) pandapipes.create_ext_grid(net, j10, 1, 320.15, type="pt", index=1) - pandapipes.create_pipe_from_parameters(net, j1, j2, 0.1, 0.1, alpha_w_per_m2k=5, index=3) - pandapipes.create_pipe_from_parameters(net, j1, j3, 0.1, 0.1, alpha_w_per_m2k=5, index=4) - pandapipes.create_pipe_from_parameters(net, j2, j4, 0.1, 0.1, alpha_w_per_m2k=5, + pandapipes.create_pipe_from_parameters(net, j1, j2, 0.1, 0.1, u_w_per_m2k=5, index=3) + pandapipes.create_pipe_from_parameters(net, j1, j3, 0.1, 0.1, u_w_per_m2k=5, index=4) + pandapipes.create_pipe_from_parameters(net, j2, j4, 0.1, 0.1, u_w_per_m2k=5, in_service=False, index=5) - pandapipes.create_pipe_from_parameters(net, j3, j5, 0.1, 0.1, alpha_w_per_m2k=5, + pandapipes.create_pipe_from_parameters(net, j3, j5, 0.1, 0.1, u_w_per_m2k=5, in_service=False, index=7) - pandapipes.create_pipe_from_parameters(net, j6, j7, 0.1, 0.1, alpha_w_per_m2k=5, index=9) - pandapipes.create_pipe_from_parameters(net, j5, j8, 0.1, 0.1, alpha_w_per_m2k=5, + pandapipes.create_pipe_from_parameters(net, j6, j7, 0.1, 0.1, u_w_per_m2k=5, index=9) + pandapipes.create_pipe_from_parameters(net, j5, j8, 0.1, 0.1, u_w_per_m2k=5, in_service=False, index=8) - pandapipes.create_pipe_from_parameters(net, j8, j10, 0.1, 0.1, alpha_w_per_m2k=5, index=1) - pandapipes.create_pipe_from_parameters(net, j9, j10, 0.1, 0.1, alpha_w_per_m2k=5, index=2) + pandapipes.create_pipe_from_parameters(net, j8, j10, 0.1, 0.1, u_w_per_m2k=5, index=1) + pandapipes.create_pipe_from_parameters(net, j9, j10, 0.1, 0.1, u_w_per_m2k=5, index=2) pandapipes.create_valve(net, j5, j6, 0.1, index=10) pandapipes.create_valve(net, j4, j5, 0.1, opened=False, index=12) @@ -139,7 +139,7 @@ def create_net_wo_ext_grid(): name="Junction 10", in_service=True, type="junction", geodata=(2, 0)) pandapipes.create_pipe_from_parameters(net, 9, 10, length_km=1, diameter_m=0.03, k_mm=.1, sections=10, - alpha_w_per_m2k=1, name="Pipe 6") + u_w_per_m2k=1, name="Pipe 6") pandapipes.create_sink(net, 9, mdot_kg_per_s=0.01, name="Sink 3") pandapipes.create_source(net, junction=10, mdot_kg_per_s=0.04, name="Source 3") pandapipes.create_compressor(net, from_junction=9, to_junction=3, pressure_ratio=1.1, @@ -408,7 +408,7 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): net.pipe.loc[[7, 8], 'in_service'] = True j_new = pandapipes.create_junction(net, 1, 320.15) - pandapipes.create_pipe_from_parameters(net, 8, j_new, 0.1, 0.1, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, 8, j_new, 0.1, 0.1, u_w_per_m2k=5) net2 = copy.deepcopy(net) @@ -429,7 +429,7 @@ def test_connectivity_heat5(complex_heat_connectivity_grid, use_numba): j_from, j_to = pandapipes.create_junctions(net, 2, 1, 320.15) - pandapipes.create_pipe_from_parameters(net, j_from, j_to, 0.1, 0.1, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j_from, j_to, 0.1, 0.1, u_w_per_m2k=5) pandapipes.create_sink(net, j_to, 0.1) pandapipes.create_ext_grid(net, j_from, 1, 320.15) diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 44d85e71f..869c4f480 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -85,7 +85,7 @@ def test_temperature_internal_nodes_single_pipe(use_numba): d = 75e-3 pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) - pandapipes.create_pipe_from_parameters(net, 0, 1, 6, d, k_mm=.1, sections=6, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, 0, 1, 6, d, k_mm=.1, sections=6, u_w_per_m2k=5) pandapipes.create_ext_grid(net, 0, p_bar=5, t_k=330, type="pt") pandapipes.create_sink(net, 1, mdot_kg_per_s=1) @@ -140,9 +140,9 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): pandapipes.create_sink(net, j2, mdot_kg_per_s=1) pandapipes.create_sink(net, j3, mdot_kg_per_s=1) - pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=.1, u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -178,11 +178,11 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=3, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, sections=3, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, sections=3, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_ext_grid(net, j0, p_bar=5, t_k=350, type="pt") pandapipes.create_ext_grid(net, j1, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j3, mdot_kg_per_s=1) @@ -224,11 +224,11 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): pandapipes.create_sink(net, j3, mdot_kg_per_s=1) pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j1, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -268,10 +268,10 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): pandapipes.create_sink(net, j3, mdot_kg_per_s=1) pandapipes.create_sink(net, j4, mdot_kg_per_s=1) - pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, d, k_mm=.1, alpha_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, d, k_mm=.1, u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -307,13 +307,13 @@ def test_temperature_internal_nodes_masche_1load(use_numba): j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j3, j2, 2.5, d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_ext_grid(net, j0, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j2, mdot_kg_per_s=1) @@ -351,11 +351,11 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j0, j3, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_pipe_from_parameters(net, j3, j2, 2.5, d, k_mm=.1, sections=5, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index c982dd8b4..cdf347274 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -25,7 +25,7 @@ def simple_test_net(): pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(net, 0, 1, 6, diameter_m=d, k_mm=.1, sections=1, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_ext_grid(net, 0, p_bar=5, t_k=330, type="pt") pandapipes.create_sink(net, 1, mdot_kg_per_s=1) @@ -76,7 +76,7 @@ def test_heat_only(use_numba): pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(net, 0, 1, 6, diameter_m=d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_ext_grid(net, 0, p_bar=5, t_k=330, type="pt") pandapipes.create_sink(net, 1, mdot_kg_per_s=1) @@ -93,7 +93,7 @@ def test_heat_only(use_numba): pandapipes.create_junction(ntw, pn_bar=5, tfluid_k=283) pandapipes.create_junction(ntw, pn_bar=5, tfluid_k=283) pandapipes.create_pipe_from_parameters(ntw, 0, 1, 6, diameter_m=d, k_mm=.1, sections=6, - alpha_w_per_m2k=5) + u_w_per_m2k=5) pandapipes.create_ext_grid(ntw, 0, p_bar=5, t_k=330, type="pt") pandapipes.create_sink(ntw, 1, mdot_kg_per_s=1) From 626218e39d486b94269c4741e4459e9cdcc700b8 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 15 Apr 2024 08:44:03 +0200 Subject: [PATCH 143/237] -changed version tag --- src/pandapipes/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index f8e6f2dec..03b635c7b 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -2,8 +2,8 @@ # 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. -__version__ = '0.10.0' -__format_version__ = '0.10.0' +__version__ = '0.10.1' +__format_version__ = '0.10.1' import pandas as pd import os From b3e7f7a1d235b24f28a1f5a4c75a023b42bdc683 Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:47:31 +0200 Subject: [PATCH 144/237] Update CHANGELOG.rst --- CHANGELOG.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3e79f9eb2..f363126dd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Change Log ============= +[0.10.0] - +- [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" +- [ADDED] variable "u_w_per_m2k" to std_type pipe +- [ADDED] standard district heating pipe types + + [0.10.0] - 2024-04-09 ------------------------------- From 70d6b2150b5cf40fad312fb14abb5563664877b9 Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:48:24 +0200 Subject: [PATCH 145/237] Update CHANGELOG.rst --- CHANGELOG.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f363126dd..1954c56f0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,9 @@ Change Log ============= + [0.10.0] - +------------------------------- + - [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types From c8f763251df53fcca0a7dba06fd00f00e56aaeb2 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 15 Apr 2024 12:43:16 +0200 Subject: [PATCH 146/237] -changed if check for alpha --- src/pandapipes/create.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 5f3d7f622..23b59cd83 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -506,21 +506,23 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam index = _get_index_with_check(net, "pipe", index) _check_branch(net, "Pipe", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, - "sections": sections, "in_service": bool(in_service), - "type": type, "qext_w": qext_w, "text_k": text_k} + #Check if alpha parameter was declared (Alpha has been changed to U) if 'alpha_w_per_m2k' in kwargs: - u_w_per_m2k = alpa_w_per_m2k + + if u_w_per_m2k == 0: + u_w_per_m2k = kwargs['alpha_w_per_m2k'] raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.' ' In the future alpha will be renamed to u.' ' Please define only one variable for the heat transfer coefficient. ' 'u will be overwritten by alpha') - + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, + "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, + "sections": sections, "in_service": bool(in_service), + "type": type, "qext_w": qext_w, "text_k": text_k} if 'std_type' in kwargs: raise UserWarning('you have defined a std_type, however, using this function you can only ' From 7bedd1ae5cdccbd4526377502ba5feb3286fb750 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 15 Apr 2024 15:05:45 +0200 Subject: [PATCH 147/237] -changed if check for alpha --- src/pandapipes/create.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 23b59cd83..298f683c7 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -513,10 +513,7 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam if u_w_per_m2k == 0: u_w_per_m2k = kwargs['alpha_w_per_m2k'] - raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.' - ' In the future alpha will be renamed to u.' - ' Please define only one variable for the heat transfer coefficient. ' - 'u will be overwritten by alpha') + raise DeprecationWarning(' In the future alpha will be renamed to u') v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, @@ -1448,18 +1445,19 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d index = _get_multiple_index_with_check(net, "pipe", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "pipe") + if 'alpha_w_per_m2k' in kwargs: + + if u_w_per_m2k == 0: + u_w_per_m2k = kwargs['alpha_w_per_m2k'] + + raise DeprecationWarning(' In the future alpha will be renamed to u') + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k, "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} - if 'alpha_w_per_m2k' in kwargs: - u_w_per_m2k = alpha_w_per_m2k - raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.' - ' In the future alpha will be renamed to u.' - ' Please define only one variable for the heat transfer coefficient. ' - 'u will be overwritten by alpha') From fff3d88b8f67ac7a96387fa002eba2ccf8fc748c Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 15 Apr 2024 15:36:24 +0200 Subject: [PATCH 148/237] -changed tutorials --- tutorials/circular_flow_in_a_district_heating_grid.ipynb | 4 ++-- tutorials/height_difference_example.ipynb | 4 ++-- tutorials/temperature_calculation.ipynb | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tutorials/circular_flow_in_a_district_heating_grid.ipynb b/tutorials/circular_flow_in_a_district_heating_grid.ipynb index a06e23669..4b0e11a02 100644 --- a/tutorials/circular_flow_in_a_district_heating_grid.ipynb +++ b/tutorials/circular_flow_in_a_district_heating_grid.ipynb @@ -112,9 +112,9 @@ "outputs": [], "source": [ "pp.create_pipe_from_parameters(net, from_junction=j0, to_junction=j1, length_km=1,\n", - " diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections = 5, text_k=283)\n", + " diameter_m=200e-3, k_mm=.1, u_w_per_m2k=10, sections = 5, text_k=283)\n", "pp.create_pipe_from_parameters(net, from_junction=j2, to_junction=j3, length_km=1,\n", - " diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections = 5, text_k=283)" + " diameter_m=200e-3, k_mm=.1, u_w_per_m2k=10, sections = 5, text_k=283)" ] }, { diff --git a/tutorials/height_difference_example.ipynb b/tutorials/height_difference_example.ipynb index 9ad39155f..324a1b8f6 100644 --- a/tutorials/height_difference_example.ipynb +++ b/tutorials/height_difference_example.ipynb @@ -188,8 +188,8 @@ "outputs": [ { "data": { - "text/plain": " name from_junction to_junction std_type length_km diameter_m k_mm \\\n0 Pipe 1 0 1 None 0.545 0.20 1.0 \n1 Pipe 2 1 2 None 0.095 0.15 1.0 \n2 Pipe 3 0 3 None 0.285 0.15 1.0 \n3 Pipe 4 0 4 None 0.430 0.15 0.5 \n\n loss_coefficient alpha_w_per_m2k text_k qext_w sections in_service \\\n0 0.0 0.0 293.0 0.0 1 True \n1 0.0 0.0 293.0 0.0 1 True \n2 0.0 0.0 293.0 0.0 1 True \n3 0.0 0.0 293.0 0.0 1 True \n\n type \n0 pipe \n1 pipe \n2 pipe \n3 pipe ", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namefrom_junctionto_junctionstd_typelength_kmdiameter_mk_mmloss_coefficientalpha_w_per_m2ktext_kqext_wsectionsin_servicetype
0Pipe 101None0.5450.201.00.00.0293.00.01Truepipe
1Pipe 212None0.0950.151.00.00.0293.00.01Truepipe
2Pipe 303None0.2850.151.00.00.0293.00.01Truepipe
3Pipe 404None0.4300.150.50.00.0293.00.01Truepipe
\n
" + "text/plain": " name from_junction to_junction std_type length_km diameter_m k_mm \\\n0 Pipe 1 0 1 None 0.545 0.20 1.0 \n1 Pipe 2 1 2 None 0.095 0.15 1.0 \n2 Pipe 3 0 3 None 0.285 0.15 1.0 \n3 Pipe 4 0 4 None 0.430 0.15 0.5 \n\n loss_coefficient u_w_per_m2k text_k qext_w sections in_service \\\n0 0.0 0.0 293.0 0.0 1 True \n1 0.0 0.0 293.0 0.0 1 True \n2 0.0 0.0 293.0 0.0 1 True \n3 0.0 0.0 293.0 0.0 1 True \n\n type \n0 pipe \n1 pipe \n2 pipe \n3 pipe ", + "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namefrom_junctionto_junctionstd_typelength_kmdiameter_mk_mmloss_coefficientu_w_per_m2ktext_kqext_wsectionsin_servicetype
0Pipe 101None0.5450.201.00.00.0293.00.01Truepipe
1Pipe 212None0.0950.151.00.00.0293.00.01Truepipe
2Pipe 303None0.2850.151.00.00.0293.00.01Truepipe
3Pipe 404None0.4300.150.50.00.0293.00.01Truepipe
\n
" }, "execution_count": 7, "metadata": {}, diff --git a/tutorials/temperature_calculation.ipynb b/tutorials/temperature_calculation.ipynb index 1cad6d87f..092634e75 100644 --- a/tutorials/temperature_calculation.ipynb +++ b/tutorials/temperature_calculation.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This tutorial describes how temperatures inside pipes can be calculated. In comparison to the hydraulic property calculation, additional parameters must be specified for the pipes: The heat transfer coefficient (`alpha_w_per_m2k`), which determines how well or poorly the pipe insulates. Likewise the ambient temperature of the pipe (`text_k`) can be changed, which is 293 K by default. To increase the spatial resolution of the pipe, more than one section can be defined using the parameter `sections`.\n", + "This tutorial describes how temperatures inside pipes can be calculated. In comparison to the hydraulic property calculation, additional parameters must be specified for the pipes: The heat transfer coefficient (`u_w_per_m2k`), which determines how well or poorly the pipe insulates. Likewise the ambient temperature of the pipe (`text_k`) can be changed, which is 293 K by default. To increase the spatial resolution of the pipe, more than one section can be defined using the parameter `sections`.\n", "\n", "Please note that only incompressible media should be used for the heating network calculation and the [`mode`](https://pandapipes.readthedocs.io/en/latest/pipeflow/calculation_modes.html#temperature-calculations-pipeflow-option-mode-all-or-mode-heat) in the `pipeflow` function has to be set to \"all\" or \"heat\". In case `mode` equals \"heat\", the user must manually specify a solution vector for the hydraulic calculations. It should also be noted that the temperature calculations are currently still sequential. This means that the calculated temperature values do not influence the fluid properties of the medium (density and viscosity). Therefore, the calculations are only valid if the properties are not very temperature-dependent or if there are minor changes in temperature.\n", " \n", @@ -104,15 +104,15 @@ "\n", "# create pipes\n", "pandapipes.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction2, length_km=0.1,\n", - " diameter_m=0.075, k_mm=0.025, sections=5, alpha_w_per_m2k=100,\n", + " diameter_m=0.075, k_mm=0.025, sections=5, u_w_per_m2k=100,\n", " text_k=298.15, name=\"Pipe 1\")\n", "\n", "pandapipes.create_pipe_from_parameters(net, from_junction=junction2, to_junction=junction3, length_km=2,\n", - " diameter_m=0.05, k_mm=0.025, sections=4, alpha_w_per_m2k=100,\n", + " diameter_m=0.05, k_mm=0.025, sections=4, u_w_per_m2k=100,\n", " text_k=298.15, name=\"Pipe 2\")\n", "\n", "pandapipes.create_pipe_from_parameters(net, from_junction=junction2, to_junction=junction4, length_km=1,\n", - " diameter_m=0.1, k_mm=0.025, sections=8, alpha_w_per_m2k=50,\n", + " diameter_m=0.1, k_mm=0.025, sections=8, u_w_per_m2k=50,\n", " text_k=298.15, name=\"Pipe 3\")" ] }, From dca8f9e909aac341b420b3e891200200e0ccd4d0 Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:46:06 +0200 Subject: [PATCH 149/237] Update CHANGELOG.rst --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1954c56f0..c60bee372 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change Log ============= -[0.10.0] - +[0.10.1] - ------------------------------- - [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" From 6cc6ba944571897cad74edbce5cff16858d4d2b0 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Wed, 17 Apr 2024 11:51:55 +0200 Subject: [PATCH 150/237] - circulation pumps are considered as default slack nodes as well - unsupplied junctions will not be plottet --- src/pandapipes/plotting/pipeflow_results.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index c3810043b..bc32fc810 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -7,6 +7,7 @@ import pandas as pd import matplotlib.pyplot as plt import numpy as np +from warnings import warn def pressure_profile_to_junction_geodata(net): @@ -89,10 +90,21 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control if pipes is None: pipes = net.pipe.index if x0_junctions is None: - x0_junctions = net.ext_grid[net.ext_grid.in_service].junction.values.tolist() + x0_junctions = set(net.ext_grid[net.ext_grid.in_service].junction.values) + if hasattr(net, "circ_pump_pressure"): + x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].junction.values) + if hasattr(net, "circ_pump_mass"): + x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].junction.values) + x0_junctions = list(x0_junctions) + + unsupplied_junctions = list(top.unsupplied_junctions(net, slacks=set(x0_junctions))) + if len(unsupplied_junctions) > 0: + warn(UserWarning(f'There are unsupplied junctions in the net, they will not be plottet: {unsupplied_junctions}')) + pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes) & + ~net.pipe.from_junction.isin(unsupplied_junctions) & + ~net.pipe.to_junction.isin(unsupplied_junctions)] d = top.calc_distance_to_junctions(net, x0_junctions) - pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)] x = np.array([d.loc[pipe_table.from_junction].values, d.loc[pipe_table.to_junction].values]) + x0 y = np.array([net.res_junction.p_bar.loc[pipe_table.from_junction].values, net.res_junction.p_bar.loc[pipe_table.to_junction].values]) From fd28d8ea6b2f6d98e2f9cf3d034a1b0e576badf2 Mon Sep 17 00:00:00 2001 From: SRDM Date: Thu, 18 Apr 2024 10:35:56 +0200 Subject: [PATCH 151/237] introducing bidirectional calculation --- doc/source/pipeflow/calculation_modes.rst | 6 +- .../abstract_models/branch_models.py | 5 +- .../component_models/component_toolbox.py | 8 +- .../heat_consumer_component.py | 185 ++++----- .../component_models/junction_component.py | 4 +- .../component_models/pipe_component.py | 4 +- .../converter/stanet/preparing_steps.py | 2 +- src/pandapipes/create.py | 353 ++++++++---------- src/pandapipes/pf/derivative_toolbox_numba.py | 5 +- src/pandapipes/pf/pipeflow_setup.py | 43 ++- src/pandapipes/pf/result_extraction.py | 21 +- src/pandapipes/pipeflow.py | 297 +++++++-------- .../test_components/test_circ_pump_mass.py | 2 +- .../test_circ_pump_pressure.py | 2 +- .../test/api/test_components/test_ext_grid.py | 20 +- .../api/test_components/test_flow_control.py | 4 +- .../api/test_components/test_heat_consumer.py | 94 +++-- .../test_components/test_heat_exchanger.py | 2 +- src/pandapipes/test/api/test_time_series.py | 4 +- .../test_heat_transfer_openmodelica.py | 16 +- .../test/pipeflow_internals/test_inservice.py | 16 +- .../test/pipeflow_internals/test_options.py | 12 +- .../test_pipeflow_analytic_comparison.py | 14 +- .../pipeflow_internals/test_pipeflow_modes.py | 2 +- src/pandapipes/test/test_toolbox.py | 1 - ...ular_flow_in_a_district_heating_grid.ipynb | 2 +- 26 files changed, 569 insertions(+), 555 deletions(-) diff --git a/doc/source/pipeflow/calculation_modes.rst b/doc/source/pipeflow/calculation_modes.rst index 6a8b38bbe..b94dc4a81 100644 --- a/doc/source/pipeflow/calculation_modes.rst +++ b/doc/source/pipeflow/calculation_modes.rst @@ -34,7 +34,7 @@ variations are very small. The user has to decide if these assumptions are suitable for his purposes. In future, pandapipes will be extended in order to make sure that calculated temperatures also effect hydraulic fluid properties. To activate temperature calculation, the pipe flow option "mode" has to be set -to "all" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually. +to "sequential", "bidirectional" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually. Hydraulic calculations for incompressible media @@ -92,8 +92,8 @@ In gas flows, the velocity is typically not constant along a pipeline. For this tables for pipes show more entries in comparison with the result tables for incompressible media. -Temperature calculations (pipeflow option: mode = "all" or mode = "heat") -========================================================================= +Temperature calculations (pipeflow option: mode = "sequential", mode = "bidrectional" or mode = "heat") +======================================================================================================= Important parameters of the network main components (junctions and pipes) needed for the calculation are listed in the following table. The :ref:`component section ` of this manual contains diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index 8ebf80323..a486fabaa 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -5,8 +5,8 @@ import numpy as np from pandapipes.component_models.abstract_models.base_component import Component -from pandapipes.idx_branch import MDOTINIT, branch_cols -from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup +from pandapipes.idx_branch import MDOTINIT, branch_cols, TEXT +from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option try: import pandaplan.core.pplog as logging @@ -89,6 +89,7 @@ def create_pit_branch_entries(cls, net, branch_pit): to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) branch_component_pit[:, MDOTINIT] = 0.1 + branch_component_pit[:, TEXT] = get_net_option(net, 'ambient_temperature') return branch_component_pit, node_pit, from_nodes, to_nodes @classmethod diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 840929bc4..67813dcb9 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -137,10 +137,10 @@ def set_entry_check_repeat(pit, column, entry, repeat_number, repeated=True): def set_fixed_node_entries(net, node_pit, junctions, eg_types, p_values, t_values, node_comp, - mode="all"): + mode="sequential"): junction_idx_lookups = get_lookup(net, "node", "index")[node_comp.table_name()] for eg_type in ("p", "t"): - if eg_type not in mode and mode != "all": + if eg_type not in mode and mode != "sequential" and mode!= "bidrectional": continue if eg_type == "p": val_col, type_col, eg_count_col, typ, valid_types, values = \ @@ -200,7 +200,7 @@ def standard_branch_wo_internals_result_lookup(net): return required_results_hyd, required_results_ht -def get_component_array(net, component_name, component_type="branch", only_active=True): +def get_component_array(net, component_name, component_type="branch", mode='hydraulics', only_active=True): """ Returns the internal array of a component. @@ -218,5 +218,5 @@ def get_component_array(net, component_name, component_type="branch", only_activ f_all, t_all = get_lookup(net, component_type, "from_to")[component_name] if not only_active: return net["_pit"]["components"][component_name] - in_service_elm = get_lookup(net, component_type, "active_hydraulics")[f_all:t_all] + in_service_elm = get_lookup(net, component_type, "active_%s"%mode)[f_all:t_all] return net["_pit"]["components"][component_name][in_service_elm] diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index f2f4aaf71..064c63d0c 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -5,12 +5,14 @@ import numpy as np from numpy import dtype -from pandapipes.component_models import get_fluid, \ - BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup +from pandapipes.component_models import get_fluid, BranchWZeroLengthComponent, get_component_array, \ + standard_branch_wo_internals_result_lookup from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, \ - JAC_DERIV_DM, JAC_DERIV_DP, LOAD_VEC_BRANCHES +from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, \ + LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE +from pandapipes.idx_node import TINIT from pandapipes.pf.result_extraction import extract_branch_results_without_internals +from pandapipes.properties.properties_toolbox import get_branch_cp class HeatConsumer(BranchWZeroLengthComponent): @@ -26,17 +28,11 @@ class HeatConsumer(BranchWZeroLengthComponent): internal_cols = 5 - # numbering of given parameters (for mdot, qext, deltat, treturn) - MF = 0 - QE = 1 - DT = 2 - TR = 3 - # heat consumer modes (sum of combinations of given parameters) - MF_QE = 1 - MF_DT = 2 - MF_TR = 4 - QE_DT = 3 + MF_DT = 1 + MF_TR = 2 + QE_MF = 3 + QE_DT = 4 QE_TR = 5 @classmethod @@ -65,12 +61,16 @@ def create_pit_branch_entries(cls, net, branch_pit): :type branch_pit: :return: No Output. """ - hs_pit = super().create_pit_branch_entries(net, branch_pit) - hs_pit[:, D] = net[cls.table_name()].diameter_m.values - hs_pit[:, AREA] = hs_pit[:, D] ** 2 * np.pi / 4 - hs_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values - hs_pit[:, QEXT] = net[cls.table_name()].qext_w.values - return hs_pit + node_pit = net['_pit']['node'] + hc_pit = super().create_pit_branch_entries(net, branch_pit) + hc_pit[:, D] = net[cls.table_name()].diameter_m.values + hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 + hc_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values + hc_pit[:, QEXT] = net[cls.table_name()].qext_w.values + # causes otherwise problems in case of mode Q + hc_pit[np.isnan(hc_pit[:, MDOTINIT]), MDOTINIT] = 0.1 + hc_pit[hc_pit[:, QEXT] == 0, ACTIVE] = False + return hc_pit @classmethod def create_component_array(cls, net, component_pits): @@ -95,9 +95,26 @@ def create_component_array(cls, net, component_pits): qe = ~np.isnan(consumer_array[:, cls.QEXT]) dt = ~np.isnan(consumer_array[:, cls.DELTAT]) tr = ~np.isnan(consumer_array[:, cls.TRETURN]) - consumer_array[:, cls.MODE] = np.sum([mf, qe, dt, tr], axis=0) + consumer_array[mf & dt, cls.MODE] = cls.MF_DT + consumer_array[mf & tr, cls.MODE] = cls.MF_TR + consumer_array[qe & mf, cls.MODE] = cls.QE_MF + consumer_array[qe & dt, cls.MODE] = cls.QE_DT + consumer_array[qe & tr, cls.MODE] = cls.QE_TR component_pits[cls.table_name()] = consumer_array + @classmethod + def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name()) + + mask = consumer_array[:, cls.MODE] == cls.QE_DT + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + deltat = net[cls.table_name()].deltat_k.values + mass = consumer_array[mask, cls.QEXT] / (cp[mask] * (deltat[mask])) + hc_pit[mask, MDOTINIT] = mass + @classmethod def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): """ @@ -119,50 +136,59 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo # set all pressure derivatives to 0 and velocity to 1; load vector must be 0, as no change # of velocity is allowed during the pipeflow iteration f, t = idx_lookups[cls.table_name()] - fc_branch_pit = branch_pit[f:t, :] - fc_array = get_component_array(net, cls.table_name()) - # TODO: this is more precise, but slower: - # np.isin(fc_array[:, cls.MODE], [cls.MF_QE, cls.MF_DT, cls.MF_TR]) - mdot_controlled = ~np.isnan(fc_array[:, cls.MASS]) - fc_branch_pit[mdot_controlled, JAC_DERIV_DP] = 0 - fc_branch_pit[mdot_controlled, JAC_DERIV_DP1] = 0 - fc_branch_pit[mdot_controlled, JAC_DERIV_DM] = 1 - fc_branch_pit[mdot_controlled, LOAD_VEC_BRANCHES] = 0 - - # @classmethod - # def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): - # f, t = idx_lookups[cls.table_name()] - # hs_pit = branch_pit[f:t, :] - # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) - # hs_pit[mask_t_return, TINIT_OUT] = (hs_pit[mask_t_return, TINIT_OUT] - # - hs_pit[mask_t_return, DELTAT]) - # - # - # @classmethod - # def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): - # """ - # - # :param net: - # :type net: - # :param branch_component_pit: - # :type branch_component_pit: - # :param node_pit: - # :type node_pit: - # :return: - # :rtype: - # """ - # # -(rho * area * cp * v_init * (-t_init_i + t_init_i1 - tl) - # # - alpha * (t_amb - t_m) * length + qext) - # - # f, t = idx_lookups[cls.table_name()] - # hs_pit = branch_pit[f:t, :] - # from_nodes = hs_pit[:, FROM_NODE_T].astype(np.int32) - # - # mask_qext = ~np.isnan(hs_pit[:, QEXT]) - # mask_deltat = ~np.isnan(hs_pit[:, DELTAT]) - # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) - # mask_mass = ~np.isnan(hs_pit[:, MASS]) - # hs_pit[mask_t_return | mask_deltat, JAC_DERIV_DT1] = 0 + consumer_array = get_component_array(net, cls.table_name()) + + hc_pit = branch_pit[f:t, :] + hc_pit[:, JAC_DERIV_DP] = 0 + hc_pit[:, JAC_DERIV_DP1] = 0 + hc_pit[:, JAC_DERIV_DM] = 1 + hc_pit[:, LOAD_VEC_BRANCHES] = 0 + + mask = consumer_array[:, cls.MODE] == cls.QE_TR + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) + t_out = consumer_array[mask, cls.TRETURN] + t_mask = hc_pit[mask, TOUTINIT] == node_pit[from_nodes, TINIT] + node_pit[from_nodes[t_mask], TINIT] += 10 + t_in = node_pit[from_nodes, TINIT] + df_dm = - cp[mask] * (t_out - t_in) + hc_pit[mask, LOAD_VEC_BRANCHES] = - consumer_array[mask, cls.QEXT] + df_dm * hc_pit[mask, MDOTINIT] + hc_pit[mask, JAC_DERIV_DM] = df_dm + + @classmethod + def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') + mask = consumer_array[:, cls.MODE] == cls.MF_DT + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + q_ext = cp[mask] * consumer_array[mask, cls.MASS] * consumer_array[mask, cls.DELTAT] + hc_pit[mask, QEXT] = q_ext + + mask = consumer_array[:, cls.MODE] == cls.MF_TR + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) + t_in = node_pit[from_nodes, TINIT] + t_out = hc_pit[mask, TOUTINIT] + q_ext = cp[mask] * consumer_array[mask, cls.MASS] * (t_in - t_out) + hc_pit[mask, QEXT] = q_ext + + @classmethod + def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') + + # Any MODE where TRETURN is given + mask = np.isin(consumer_array[:, cls.MODE], [cls.MF_TR, cls.QE_TR]) + if np.any(mask): + hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0 + hc_pit[mask, JAC_DERIV_DTOUT] = -1 + hc_pit[mask, JAC_DERIV_DT] = 0 + hc_pit[mask, TOUTINIT] = consumer_array[mask, cls.TRETURN] @classmethod def get_component_input(cls): @@ -173,16 +199,9 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), - ("from_junction", "u4"), - ("to_junction", "u4"), - ("qext_w", "f8"), - ("controlled_mdot_kg_per_s", "f8"), - ("deltat_k", "f8"), - ("treturn_k", "f8"), - ("diameter_m", "f8"), - ("in_service", "bool"), - ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), + ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), + ("in_service", "bool"), ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -197,14 +216,12 @@ def get_result_table(cls, net): :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"] + 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"] + 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 @classmethod @@ -224,5 +241,5 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals(net, branch_results, required_results_hyd, - required_results_ht, cls.table_name(), mode) + extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, + cls.table_name(), mode) diff --git a/src/pandapipes/component_models/junction_component.py b/src/pandapipes/component_models/junction_component.py index 2f0f77ed5..67cbcd14a 100644 --- a/src/pandapipes/component_models/junction_component.py +++ b/src/pandapipes/component_models/junction_component.py @@ -107,7 +107,7 @@ def extract_results(cls, net, options, branch_results, mode): f, t = get_lookup(net, "node", "from_to")[cls.table_name()] junction_pit = net["_pit"]["node"][f:t, :] - if mode in ["hydraulics", "all"]: + if mode in ["hydraulics", "sequential", "bidirectional"]: junctions_connected_hydraulic = get_lookup(net, "node", "active_hydraulics")[f:t] if np.any(junction_pit[junctions_connected_hydraulic, PINIT] < 0): @@ -119,7 +119,7 @@ def extract_results(cls, net, options, branch_results, mode): # if mode == "hydraulics": # res_table["t_k"].values[junctions_connected_hydraulic] = junction_pit[:, TINIT] # - # if mode in ["heat", "all"]: + # if mode in ["heat", "sequential", "bidirectional]: # junctions_connected_ht = get_lookup(net, "node", "active_heat_transfer")[f:t] # res_table["t_k"].values[junctions_connected_ht] = junction_pit[:, TINIT] res_table["p_bar"].values[:] = junction_pit[:, PINIT] diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 3492b6c79..2175c6999 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -13,7 +13,7 @@ from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \ MDOTINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC from pandapipes.idx_node import PINIT, TINIT as TINIT_NODE, PAMB -from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup +from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup, get_net_option from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \ extract_branch_results_without_internals @@ -122,6 +122,8 @@ def create_pit_branch_entries(cls, net, branch_pit): set_entry_check_repeat( pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals) + nan_mask = np.isnan(pipe_pit[:, TEXT]) + pipe_pit[nan_mask, TEXT] = get_net_option(net, 'ambient_temperature') pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4 pipe_pit[:, MDOTINIT] *= pipe_pit[:, AREA] * get_fluid(net).get_density(NORMAL_TEMPERATURE) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index f3edbcb94..e423fa5ff 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -182,7 +182,7 @@ def get_net_params(net, stored_data): net_params["t_sutherland"] = net_data.at[0, "TS"] net_params["t0_sutherland"] = net_data.at[0, "T0"] net_params["calculate_temp"] = str(net_data.at[0, "TEMPCALC"]) == "J" - pp_calc_mode = "all" if net_params["calculate_temp"] else "hydraulics" + pp_calc_mode = "sequential" if net_params["calculate_temp"] else "hydraulics" pandapipes.set_user_pf_options(net, mode=pp_calc_mode) net_params["medium_temp_C"] = net_data.at[0, "TEMP"] net_params["medium_temp_K"] = net_data.at[0, "TEMP"] + 273.15 diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index bf05b253a..55c8ac8ef 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,13 +4,12 @@ import numpy as np import pandas as pd -from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ - _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ - _add_multiple_branch_geodata, _check_branch_element, _check_multiple_branch_elements +from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, _check_node_element, \ + _check_multiple_node_elements, _set_multiple_entries, _add_multiple_branch_geodata, _check_branch_element, \ + _check_multiple_branch_elements -from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \ - HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, \ - Compressor, MassStorage +from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, HeatExchanger, Valve, \ + CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, Compressor, MassStorage from pandapipes.component_models.component_toolbox import add_new_component from pandapipes.component_models.flow_control_component import FlowControlComponent from pandapipes.component_models.heat_consumer_component import HeatConsumer @@ -18,8 +17,7 @@ from pandapipes.properties import call_lib from pandapipes.properties.fluids import Fluid, _add_fluid_to_net from pandapipes.std_types.std_type_class import regression_function, PumpStdType -from pandapipes.std_types.std_types import add_basic_std_types, create_pump_std_type, \ - load_std_type +from pandapipes.std_types.std_types import add_basic_std_types, create_pump_std_type, load_std_type try: import pandaplan.core.pplog as logging @@ -67,8 +65,8 @@ def create_empty_network(name="", fluid=None, add_stdtypes=True): return net -def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, - type="junction", geodata=None, **kwargs): +def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, type="junction", + geodata=None, **kwargs): """ Adds one junction in table net["junction"]. Junctions are the nodes of the network that all other elements connect to. @@ -119,8 +117,8 @@ def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in return index -def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='sink', **kwargs): +def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='sink', + **kwargs): """ Adds one sink in table net["sink"]. @@ -162,8 +160,8 @@ def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, return index -def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='source', **kwargs): +def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='source', + **kwargs): """ Adds one source in table net["source"]. @@ -206,9 +204,8 @@ def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=Non return index -def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_stored_kg=0., - max_m_stored_kg=np.inf, scaling=1., name=None, index=None, - in_service=True, type="mass_storage", **kwargs): +def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_stored_kg=0., max_m_stored_kg=np.inf, + scaling=1., name=None, index=None, in_service=True, type="mass_storage", **kwargs): """ Adds one storage entry in table net["mass_storage"]. Not suitable for thermal storage tanks. @@ -262,17 +259,16 @@ def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_ index = _get_index_with_check(net, "mass_storage", index) - cols = ["name", "junction", "mdot_kg_per_s", "scaling", "init_m_stored_kg", "min_m_stored_kg", - "max_m_stored_kg", "in_service", "type"] - vals = [name, junction, mdot_kg_per_s, scaling, init_m_stored_kg, min_m_stored_kg, - max_m_stored_kg, bool(in_service), type] + cols = ["name", "junction", "mdot_kg_per_s", "scaling", "init_m_stored_kg", "min_m_stored_kg", "max_m_stored_kg", + "in_service", "type"] + vals = [name, junction, mdot_kg_per_s, scaling, init_m_stored_kg, min_m_stored_kg, max_m_stored_kg, + bool(in_service), type] _set_entries(net, "mass_storage", index, **dict(zip(cols, vals)), **kwargs) return index -def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, in_service=True, - index=None, **kwargs): +def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, in_service=True, index=None, **kwargs): """ Creates an external grid and adds it to the table net["ext_grid"]. It transfers the junction that it is connected to into a node with fixed value for either pressure, temperature or both @@ -326,8 +322,8 @@ def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, return index -def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, loss_coefficient=0, - name=None, index=None, in_service=True, type="heat_exchanger", **kwargs): +def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, loss_coefficient=0, name=None, + index=None, in_service=True, type="heat_exchanger", **kwargs): """ Creates a heat exchanger element in net["heat_exchanger"] from heat exchanger parameters. @@ -369,17 +365,16 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l index = _get_index_with_check(net, "heat_exchanger", index, "heat exchanger") _check_branch(net, "Heat exchanger", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "qext_w": qext_w, "loss_coefficient": loss_coefficient, - "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "qext_w": qext_w, "loss_coefficient": loss_coefficient, "in_service": bool(in_service), "type": type} _set_entries(net, "heat_exchanger", index, **v, **kwargs) return index -def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, - geodata=None, in_service=True, type="pipe", **kwargs): +def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, + alpha_w_per_m2k=0., qext_w=0., text_k=None, name=None, index=None, geodata=None, in_service=True, + type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -403,10 +398,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 - :param text_k: Ambient temperature of pipe in [K] - :type text_k: float, default 293 :param qext_w: External heat feed-in to the pipe in [W] :type qext_w: float, default 0 + :param text_k: Ambient temperature of pipe in [K] + :type text_k: float, default None, will be set equal to the net ambient temperature :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -437,12 +432,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, _check_std_type(net, std_type, "pipe", "create_pipe") pipe_parameter = load_std_type(net, std_type, "pipe") - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": std_type, "length_km": length_km, - "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, - "text_k": text_k} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, + "length_km": length_km, "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, + "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} _set_entries(net, "pipe", index, **v, **kwargs) if geodata is not None: @@ -451,10 +444,9 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, return index -def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, - qext_w=0., name=None, index=None, geodata=None, in_service=True, - type="pipe", **kwargs): +def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, + sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -510,11 +502,10 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam index = _get_index_with_check(net, "pipe", index) _check_branch(net, "Pipe", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": bool(in_service), - "type": type, "qext_w": qext_w, "text_k": text_k} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": None, + "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "loss_coefficient": loss_coefficient, + "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, + "qext_w": qext_w, "text_k": text_k} if 'std_type' in kwargs: raise UserWarning('you have defined a std_type, however, using this function you can only ' 'create a pipe setting specific, individual parameters. If you want to ' @@ -527,8 +518,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam return index -def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_coefficient=0, - name=None, index=None, type='valve', **kwargs): +def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_coefficient=0, name=None, index=None, + type='valve', **kwargs): """ Creates a valve element in net["valve"] from valve parameters. @@ -566,16 +557,15 @@ def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_ index = _get_index_with_check(net, "valve", index) _check_branch(net, "Valve", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "opened": opened, "loss_coefficient": loss_coefficient, - "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "opened": opened, "loss_coefficient": loss_coefficient, "type": type} _set_entries(net, "valve", index, **v, **kwargs) return index -def create_pump(net, from_junction, to_junction, std_type, name=None, index=None, in_service=True, - type="pump", **kwargs): +def create_pump(net, from_junction, to_junction, std_type, name=None, index=None, in_service=True, type="pump", + **kwargs): """ Adds one pump in table net["pump"]. @@ -614,17 +604,16 @@ def create_pump(net, from_junction, to_junction, std_type, name=None, index=None _check_branch(net, "Pump", index, from_junction, to_junction) _check_std_type(net, std_type, "pump", "create_pump") - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": std_type, "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, + "in_service": bool(in_service), "type": type} _set_entries(net, "pump", index, **v, **kwargs) return index -def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_name, - pressure_list=None, flowrate_list=None, reg_polynomial_degree=None, - poly_coefficents=None, name=None, index=None, in_service=True, - type="pump", **kwargs): +def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_name, pressure_list=None, + flowrate_list=None, reg_polynomial_degree=None, poly_coefficents=None, name=None, + index=None, in_service=True, type="pump", **kwargs): """ Adds one pump in table net["pump"]. @@ -685,8 +674,7 @@ def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_na index = _get_index_with_check(net, "pump", index) _check_branch(net, "Pump", index, from_junction, to_junction) - if pressure_list is not None and flowrate_list is not None \ - and reg_polynomial_degree is not None: + if pressure_list is not None and flowrate_list is not None and reg_polynomial_degree is not None: reg_par = regression_function(flowrate_list, pressure_list, reg_polynomial_degree) pump = PumpStdType(new_std_type_name, reg_par) create_pump_std_type(net, new_std_type_name, pump) @@ -694,16 +682,15 @@ def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_na pump = PumpStdType(new_std_type_name, poly_coefficents) create_pump_std_type(net, new_std_type_name, pump) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": new_std_type_name, "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": new_std_type_name, + "in_service": bool(in_service), "type": type} _set_entries(net, "pump", index, **v, **kwargs) return index -def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_bar, plift_bar, - t_flow_k=None, type="auto", name=None, index=None, - in_service=True, **kwargs): +def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_bar, plift_bar, t_flow_k=None, + type="auto", name=None, index=None, in_service=True, **kwargs): """ Adds one circulation pump with a constant pressure lift in table net["circ_pump_pressure"]. \n A circulation pump is a component that sets the pressure at its outlet (flow junction) and @@ -755,24 +742,20 @@ def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_ add_new_component(net, CirculationPumpPressure) - index = _get_index_with_check(net, "circ_pump_pressure", index, - name="circulation pump with constant pressure") - _check_branch(net, "circulation pump with constant pressure", index, return_junction, - flow_junction) + index = _get_index_with_check(net, "circ_pump_pressure", index, name="circulation pump with constant pressure") + _check_branch(net, "circulation pump with constant pressure", index, return_junction, flow_junction) type = _auto_ext_grid_type(p_flow_bar, t_flow_k, type, CirculationPumpPressure) - v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, - "p_flow_bar": p_flow_bar, "t_flow_k": t_flow_k, "plift_bar": plift_bar, "type": type, - "in_service": bool(in_service)} + v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, "p_flow_bar": p_flow_bar, + "t_flow_k": t_flow_k, "plift_bar": plift_bar, "type": type, "in_service": bool(in_service)} _set_entries(net, "circ_pump_pressure", index, **v, **kwargs) return index -def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow_bar, - mdot_flow_kg_per_s, t_flow_k=None, type="auto", name=None, - index=None, in_service=True, **kwargs): +def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow_bar, mdot_flow_kg_per_s, t_flow_k=None, + type="auto", name=None, index=None, in_service=True, **kwargs): """ Adds one circulation pump with a constant mass flow in table net["circ_pump_mass"].\n A circulation pump is a component that sets the pressure at its outlet (flow junction) and @@ -823,23 +806,20 @@ def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow add_new_component(net, CirculationPumpMass) - index = _get_index_with_check(net, "circ_pump_mass", index, - name="circulation pump with constant mass flow") - _check_branch(net, "circulation pump with constant mass flow", index, return_junction, - flow_junction) + index = _get_index_with_check(net, "circ_pump_mass", index, name="circulation pump with constant mass flow") + _check_branch(net, "circulation pump with constant mass flow", index, return_junction, flow_junction) type = _auto_ext_grid_type(p_flow_bar, t_flow_k, type, CirculationPumpMass) - v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, - "p_flow_bar": p_flow_bar, "t_flow_k": t_flow_k, "mdot_flow_kg_per_s": mdot_flow_kg_per_s, - "type": type, "in_service": bool(in_service)} + v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, "p_flow_bar": p_flow_bar, + "t_flow_k": t_flow_k, "mdot_flow_kg_per_s": mdot_flow_kg_per_s, "type": type, "in_service": bool(in_service)} _set_entries(net, "circ_pump_mass", index, **v, **kwargs) return index -def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None, index=None, - in_service=True, **kwargs): +def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None, index=None, in_service=True, + **kwargs): """Adds a compressor with relative pressure lift to net["compressor"]. The outlet (absolute) pressure is calculated by (p_in + p_ambient) * pressure_ratio. For @@ -876,16 +856,16 @@ def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None index = _get_index_with_check(net, "compressor", index) _check_branch(net, "Compressor", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "pressure_ratio": pressure_ratio, "in_service": bool(in_service)} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "pressure_ratio": pressure_ratio, + "in_service": bool(in_service)} _set_entries(net, "compressor", index, **v, **kwargs) return index -def create_pressure_control(net, from_junction, to_junction, controlled_junction, controlled_p_bar, - control_active=True, loss_coefficient=0., name=None, index=None, - in_service=True, type="pressure_control", **kwargs): +def create_pressure_control(net, from_junction, to_junction, controlled_junction, controlled_p_bar, control_active=True, + loss_coefficient=0., name=None, index=None, in_service=True, type="pressure_control", + **kwargs): """Adds one pressure control that enforces a pressure at a specific junction. The pressure control unit creates a pressure drop / lift between the 'from' and the 'to' @@ -949,11 +929,10 @@ def create_pressure_control(net, from_junction, to_junction, controlled_junction # check if junctions exist to attach the pump to _check_branch(net, "PressureControl", index, from_junction, to_junction) - _set_entries(net, "press_control", index, name=name, from_junction=from_junction, - to_junction=to_junction, controlled_junction=controlled_junction, - control_active=bool(control_active), loss_coefficient=loss_coefficient, - controlled_p_bar=controlled_p_bar, in_service=bool(in_service), type=type, - **kwargs) + _set_entries(net, "press_control", index, name=name, from_junction=from_junction, to_junction=to_junction, + controlled_junction=controlled_junction, control_active=bool(control_active), + loss_coefficient=loss_coefficient, controlled_p_bar=controlled_p_bar, in_service=bool(in_service), + type=type, **kwargs) if controlled_junction != from_junction and controlled_junction != to_junction: logger.warning("The pressure controller %d controls the pressure at a junction that it is " @@ -964,9 +943,8 @@ def create_pressure_control(net, from_junction, to_junction, controlled_junction return index -def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_s, diameter_m, - control_active=True, name=None, index=None, in_service=True, type="fc", - **kwargs): +def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_s, diameter_m, control_active=True, + name=None, index=None, in_service=True, type="fc", **kwargs): """ Adds one flow control with a constant mass flow in table net["flow_control"]. @@ -1012,17 +990,16 @@ def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_ # check if junctions exist to attach the pump to _check_branch(net, "FlowControl", index, from_junction, to_junction) - _set_entries(net, "flow_control", index, name=name, from_junction=from_junction, - to_junction=to_junction, controlled_mdot_kg_per_s=controlled_mdot_kg_per_s, - diameter_m=diameter_m, control_active=bool(control_active), - in_service=bool(in_service), type=type, **kwargs) + _set_entries(net, "flow_control", index, name=name, from_junction=from_junction, to_junction=to_junction, + controlled_mdot_kg_per_s=controlled_mdot_kg_per_s, diameter_m=diameter_m, + control_active=bool(control_active), in_service=bool(in_service), type=type, **kwargs) return index -def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=None, - controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, name=None, - index=None, in_service=True, type="heat_consumer", **kwargs): +def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=None, controlled_mdot_kg_per_s=None, + deltat_k=None, treturn_k=None, name=None, index=None, in_service=True, type="heat_consumer", + **kwargs): """ Creates a heat consumer element in net["heat_consumer"] from heat consumer parameters. @@ -1064,33 +1041,28 @@ def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=Non >>> create_heat_consumer(net,from_junction=0, to_junction=1, diameter_m=40e-3, qext_w=20000, >>> controlled_mdot_kg_per_s=0.4, name="heat_consumer1") """ - if deltat_k is not None or treturn_k is not None: - raise NotImplementedError("The models for consumers with fixed temperature difference or " - "fixed return temperature are not implemented yet.") - if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) - + (treturn_k is None) != 2): + if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) + (treturn_k is None) != 2): raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " - r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None.") + if deltat_k is not None and treturn_k is not None: raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " r"flow temperature is independent of the heat consumer model.") - add_new_component(net, HeatConsumer) index = _get_index_with_check(net, "heat_consumer", index, "heat consumer") _check_branch(net, "Heat consumer", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "qext_w": qext_w, - "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "qext_w": qext_w, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_entries(net, "heat_consumer", index, **v, **kwargs) return index -def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, index=None, - in_service=True, type="junction", geodata=None, **kwargs): +def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, + type="junction", geodata=None, **kwargs): """ Convenience function for creating many junctions at once. Parameter 'nr_junctions' specifies \ the number of junctions created. Other parameters may be either arrays of length 'nr_junctions'\ @@ -1131,8 +1103,8 @@ def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, add_new_component(net, Junction) index = _get_multiple_index_with_check(net, "junction", index, nr_junctions) - entries = {"pn_bar": pn_bar, "type": type, "tfluid_k": tfluid_k, "height_m": height_m, - "in_service": in_service, "name": name} + entries = {"pn_bar": pn_bar, "type": type, "tfluid_k": tfluid_k, "height_m": height_m, "in_service": in_service, + "name": name} _set_multiple_entries(net, "junction", index, **entries, **kwargs) if geodata is not None: @@ -1146,8 +1118,8 @@ def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, return index -def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='sink', **kwargs): +def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='sink', + **kwargs): """ Convenience function for creating many sinks at once. Parameter 'junctions' must be an array \ of the desired length. Other parameters may be either arrays of the same length or single \ @@ -1184,15 +1156,15 @@ def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=Non _check_multiple_junction_elements(net, junctions) index = _get_multiple_index_with_check(net, "sink", index, len(junctions)) - entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, "in_service": in_service, + "name": name, "type": type} _set_multiple_entries(net, "sink", index, **entries, **kwargs) return index -def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, - in_service=True, type='source', **kwargs): +def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='source', + **kwargs): """ Convenience function for creating many sources at once. Parameter 'junctions' must be an array \ of the desired length. Other parameters may be either arrays of the same length or single \ @@ -1229,15 +1201,14 @@ def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=N _check_multiple_junction_elements(net, junctions) index = _get_multiple_index_with_check(net, "source", index, len(junctions)) - entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, "in_service": in_service, + "name": name, "type": type} _set_multiple_entries(net, "source", index, **entries, **kwargs) return index -def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, index=None, - type="auto", **kwargs): +def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, index=None, type="auto", **kwargs): """ Convenience function for creating many external grids at once. Parameter 'junctions' must be an\ array of the desired length. Other parameters may be either arrays of the same length or single\ @@ -1286,16 +1257,15 @@ def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, ind type = _auto_ext_grid_types(p_bar, t_k, type, ExtGrid) - entries = {"junction": junctions, "p_bar": p_bar, "t_k": t_k, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "p_bar": p_bar, "t_k": t_k, "in_service": in_service, "name": name, "type": type} _set_multiple_entries(net, "ext_grid", index, **entries, **kwargs) return index -def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., - name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): +def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, + alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, + type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1361,12 +1331,10 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. _check_std_type(net, std_type, "pipe", "create_pipes") pipe_parameters = load_std_type(net, std_type, "pipe") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "std_type": std_type, "length_km": length_km, - "diameter_m": pipe_parameters["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, - "text_k": text_k} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": std_type, + "length_km": length_km, "diameter_m": pipe_parameters["inner_diameter_mm"] / 1000, "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, + "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} _set_multiple_entries(net, "pipe", index, **entries, **kwargs) if geodata is not None: @@ -1374,10 +1342,9 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. return index -def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, - qext_w=0., name=None, index=None, geodata=None, in_service=True, - type="pipe", **kwargs): +def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, + sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1439,11 +1406,10 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d index = _get_multiple_index_with_check(net, "pipe", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "pipe") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, - "text_k": text_k} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, + "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "loss_coefficient": loss_coefficient, + "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": in_service, "type": type, + "qext_w": qext_w, "text_k": text_k} _set_multiple_entries(net, "pipe", index, **entries, **kwargs) if geodata is not None: @@ -1451,8 +1417,8 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d return index -def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, loss_coefficient=0, - name=None, index=None, type='valve', **kwargs): +def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, loss_coefficient=0, name=None, index=None, + type='valve', **kwargs): """ Convenience function for creating many valves at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1495,17 +1461,16 @@ def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, lo index = _get_multiple_index_with_check(net, "valve", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "valve") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "opened": opened, "loss_coefficient": loss_coefficient, - "type": type} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "opened": opened, "loss_coefficient": loss_coefficient, "type": type} _set_multiple_entries(net, "valve", index, **entries, **kwargs) return index -def create_pressure_controls(net, from_junctions, to_junctions, controlled_junctions, - controlled_p_bar, control_active=True, loss_coefficient=0., name=None, - index=None, in_service=True, type="pressure_control", **kwargs): +def create_pressure_controls(net, from_junctions, to_junctions, controlled_junctions, controlled_p_bar, + control_active=True, loss_coefficient=0., name=None, index=None, in_service=True, + type="pressure_control", **kwargs): """ Convenience function for creating many pressure controls at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1568,12 +1533,11 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "controlled_junction": controlled_junctions, "controlled_p_bar": controlled_p_bar, - "control_active": control_active, "loss_coefficient": loss_coefficient, - "in_service": in_service, "type": type} + "control_active": control_active, "loss_coefficient": loss_coefficient, "in_service": in_service, + "type": type} _set_multiple_entries(net, "press_control", index, **entries, **kwargs) - controlled_elsewhere = (controlled_junctions != from_junctions) \ - & (controlled_junctions != to_junctions) + controlled_elsewhere = (controlled_junctions != from_junctions) & (controlled_junctions != to_junctions) if np.any(controlled_elsewhere): controllers_warn = index[controlled_elsewhere] logger.warning("The pressure controllers %s control the pressure at junctions that they are" @@ -1584,9 +1548,8 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct return index -def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_per_s, diameter_m, - control_active=True, name=None, index=None, in_service=True, type="fc", - **kwargs): +def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_per_s, diameter_m, control_active=True, + name=None, index=None, in_service=True, type="fc", **kwargs): """ Convenience function for creating many flow controls at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1643,9 +1606,8 @@ def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_p return index -def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, - loss_coefficient=0, name=None, index=None, in_service=True, - type="heat_exchanger", **kwargs): +def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, loss_coefficient=0, name=None, + index=None, in_service=True, type="heat_exchanger", **kwargs): """ Convenience function for creating many heat exchangers at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1691,17 +1653,16 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w index = _get_multiple_index_with_check(net, "heat_exchanger", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "heat_exchanger") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "qext_w": qext_w, "loss_coefficient": loss_coefficient, - "in_service": bool(in_service), "type": type} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "qext_w": qext_w, "loss_coefficient": loss_coefficient, "in_service": bool(in_service), "type": type} _set_multiple_entries(net, "heat_exchanger", index, **entries, **kwargs) return index -def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w=None, - controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, - name=None, index=None, in_service=True, type="heat_consumer", **kwargs): +def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w=None, controlled_mdot_kg_per_s=None, + deltat_k=None, treturn_k=None, name=None, index=None, in_service=True, type="heat_consumer", + **kwargs): """ Creates several heat consumer elements in net["heat_consumer"] from heat consumer parameters. @@ -1744,9 +1705,6 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, >>> qext_w=20000, controlled_mdot_kg_per_s=[0.5, 0.9]) """ - if np.any(pd.notnull(deltat_k)) or np.any(pd.notnull(treturn_k)): - raise NotImplementedError("The models for consumers with fixed temperature difference or " - "fixed return temperature are not implemented yet.") check_vars = [controlled_mdot_kg_per_s, qext_w, deltat_k, treturn_k] var_sums = np.zeros([4, len(from_junctions)]) for i, cv in enumerate(check_vars): @@ -1764,9 +1722,8 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= index = _get_multiple_index_with_check(net, "heat_consumer", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "heat_consumer") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "qext_w": qext_w, - "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "qext_w": qext_w, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_multiple_entries(net, "heat_consumer", index, **entries, **kwargs) return index @@ -1802,13 +1759,11 @@ def _check_junction_element(net, junction): def _check_branch(net, element_name, index, from_junction, to_junction): - return _check_branch_element(net, element_name, index, from_junction, to_junction, - node_name="junction", plural="s") + return _check_branch_element(net, element_name, index, from_junction, to_junction, node_name="junction", plural="s") def _check_branches(net, from_junctions, to_junctions, table): - return _check_multiple_branch_elements(net, from_junctions, to_junctions, table, - node_name="junction", plural="s") + return _check_multiple_branch_elements(net, from_junctions, to_junctions, table, node_name="junction", plural="s") def _check_std_type(net, std_type, table, function_name): @@ -1843,30 +1798,25 @@ def _auto_ext_grid_type(p_bar, t_k, typ, comp): p_null, t_null = p_bar is None or np.isnan(p_bar), t_k is None or np.isnan(t_k) if p_null and t_null: - raise UserWarning("For component %s, either pressure or temperature must be defined!" - % comp.__name__) + raise UserWarning("For component %s, either pressure or temperature must be defined!" % comp.__name__) if typ not in ALLOWED_EG_TYPES: logger.warning("The type for component %s was %s, but must be one of the following for " "correct model implementation: %s." % (comp.__name__, typ, ALLOWED_EG_TYPES)) if typ not in ["t", "auto"] and p_null: - raise UserWarning("The type %s for component %s requires a pressure as input!" - % (typ, comp.__name__)) + raise UserWarning("The type %s for component %s requires a pressure as input!" % (typ, comp.__name__)) if typ not in ["p", "auto"] and t_null: - raise UserWarning("The type %s for component %s requires a temperature as input!" - % (typ, comp.__name__)) + raise UserWarning("The type %s for component %s requires a temperature as input!" % (typ, comp.__name__)) if typ != "auto" and "p" not in typ and not p_null: logger.warning("For component %s you gave a value for p, although the component is not of " - "'p'-type (type is %s), i.e. this value is probably neglected internally." - % (comp, typ)) + "'p'-type (type is %s), i.e. this value is probably neglected internally." % (comp, typ)) if typ != "auto" and "t" not in typ and not t_null: logger.warning("For component %s you gave a value for t, although the component is not of " - "'t'-type (type is %s), i.e. this value is probably neglected internally." - % (comp, typ)) + "'t'-type (type is %s), i.e. this value is probably neglected internally." % (comp, typ)) if typ == "tp": logger.warning("The type 'tp' is replaced by type 'pt' (might be mistaken internally).") @@ -1910,8 +1860,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): if not any([p_arr, t_arr, typ_arr]): return _auto_ext_grid_type(p_bar, t_k, typ, comp) else: - lengths = np.array([len(arr) for arr, it in zip([p_bar, t_k, typ], [p_arr, t_arr, typ_arr]) - if it]) + lengths = np.array([len(arr) for arr, it in zip([p_bar, t_k, typ], [p_arr, t_arr, typ_arr]) if it]) if not np.array_equal(lengths[1:], lengths[:-1]): raise UserWarning("The arrays for p_bar, t_k and type must have equal length!") length = lengths[0] @@ -1940,8 +1889,8 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): pos_not_allowed_types = np.where(not_allowed_types) overview = pd.DataFrame({"Position": pos_not_allowed_types, "Type": typ_not_allowed_types}) logger.warning("Please check the following types for component %s, as they must be one of " - "the following for correct model implementation: %s. \n%s" - % (comp.__name__, ALLOWED_EG_TYPES, overview)) + "the following for correct model implementation: %s. \n%s" % ( + comp.__name__, ALLOWED_EG_TYPES, overview)) p_types = np.isin(typ, [tp for tp in ALLOWED_EG_TYPES if tp not in ["t", "auto"]]) t_types = np.isin(typ, [tp for tp in ALLOWED_EG_TYPES if tp not in ["p", "auto"]]) @@ -1964,8 +1913,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): ununsed_p = ~auto_types & ~p_null & ~p_types if np.any(ununsed_p): - overview = pd.DataFrame({"Positions": np.where(ununsed_p)[0], - "Type": np.array(typ)[ununsed_p], + overview = pd.DataFrame({"Positions": np.where(ununsed_p)[0], "Type": np.array(typ)[ununsed_p], "p_value": np.array(p_bar)[ununsed_p]}) logger.warning("For component %s you gave a value for p in some cases, although the " "respective components are not of 'p'-type, i.e. the given values are " @@ -1973,8 +1921,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): ununsed_t = ~auto_types & ~t_null & ~t_types if np.any(ununsed_t): - overview = pd.DataFrame({"Positions": np.where(ununsed_t)[0], - "Type": np.array(typ)[ununsed_t], + overview = pd.DataFrame({"Positions": np.where(ununsed_t)[0], "Type": np.array(typ)[ununsed_t], "t_value": np.array(p_bar)[ununsed_t]}) logger.warning("For component %s you gave a value for t in some cases, although the " "respective components are not of 't'-type, i.e. the given values are " diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 5cadb5524..6d9ba63e0 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -4,7 +4,7 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ - MDOTINIT, FROM_NODE, TO_NODE + MDOTINIT, FROM_NODE, TO_NODE, TOUTINIT from pandapipes.idx_node import HEIGHT, PAMB, PINIT, TINIT as TINIT_NODE try: @@ -67,8 +67,7 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, p_sum = p_init_i_abs[i] + p_init_i1_abs[i] p_sum_div = np.divide(1, p_sum) fn = from_nodes[i] - tn = to_nodes[i] - tm = (node_pit[fn, TINIT_NODE] + node_pit[tn, TINIT_NODE]) / 2 + tm = (node_pit[fn, TINIT_NODE] + branch_pit[i][TOUTINIT]) / 2 const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION friction_term = np.divide(lambda_[i] * branch_pit[i][LENGTH], branch_pit[i][D]) + \ diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 78d33e2e8..f6b16815e 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -34,10 +34,10 @@ logger = logging.getLogger(__name__) default_options = {"friction_model": "nikuradse", "tol_p": 1e-5, "tol_m": 1e-5, - "tol_T": 1e-3, "tol_res": 1e-3, "max_iter_hyd": 10, "max_iter_therm": 10, + "tol_T": 1e-3, "tol_res": 1e-3, "max_iter_hyd": 10, "max_iter_therm": 10, "max_iter_bidirect": 10, "error_flag": False, "alpha": 1, "nonlinear_method": "constant", "mode": "hydraulics", - "ambient_temperature": 293, "check_connectivity": True, + "ambient_temperature": 293.15, "check_connectivity": True, "max_iter_colebrook": 10, "only_update_hydraulic_matrix": False, "reuse_internal_data": False, "use_numba": True, "quit_on_inconsistency_connectivity": False, "calc_compression_power": True} @@ -247,8 +247,8 @@ def init_options(net, local_parameters): automatically with respect to the convergence behaviour. - **mode** (str): "hydraulics" - Define the calculation mode: what shall be calculated - \ - solely hydraulics ('hydraulics'), solely heat transfer('heat') or both combined \ - ('all'). + solely hydraulics ('hydraulics'), solely heat transfer('heat') or both combined sequentially \ + ('sequential') or bidirectionally ('bidirectional'). - **only_update_hydraulic_matrix** (bool): False - If True, the system matrix is not \ created in every iteration, but only the data is updated according to a lookup that\ @@ -292,6 +292,7 @@ def init_options(net, local_parameters): # the third layer is the user defined pipeflow options if "user_pf_options" in net and len(net.user_pf_options) > 0: opts = _iteration_check(net.user_pf_options) + opts = _check_mode(opts) net["_options"].update(opts) @@ -305,6 +306,7 @@ def init_options(net, local_parameters): params[k] = v opts = _iteration_check(local_parameters["kwargs"]) + opts = _check_mode(opts) params.update(opts) net["_options"].update(params) net["_options"]["fluid"] = get_fluid(net).name @@ -322,7 +324,7 @@ def _iteration_check(opts): iter_defined = False params = dict() if 'iter' in opts: - params['max_iter_hyd'] = params['max_iter_therm'] = opts["iter"] + params['max_iter_hyd'] = params['max_iter_therm'] = params['max_iter_bidirect'] = opts["iter"] iter_defined = True if 'max_iter_hyd' in opts: max_iter_hyd = opts["max_iter_hyd"] @@ -334,9 +336,22 @@ def _iteration_check(opts): if iter_defined: logger.info("You defined 'iter' and 'max_iter_therm. " "'max_iter_therm' will overwrite 'iter'") params['max_iter_therm'] = max_iter_therm + if 'max_iter_bidirect' in opts: + max_iter_bidirect = opts["max_iter_bidirect"] + if iter_defined: logger.info("You defined 'iter' and 'max_iter_bidirect. " + "'max_iter_bidirect' will overwrite 'iter'") + params['max_iter_bidirect'] = max_iter_bidirect opts.update(params) return opts +def _check_mode(opts): + opts = copy.deepcopy(opts) + if 'mode' in opts and opts['mode'] == 'all': + logger.warning("mode 'all' is deprecated and will be removed in a future release. " + "Use 'sequential' or 'bidirectional' instead. " + "For now 'all' is set equal to 'sequential'.") + opts['mode'] = 'sequential' + return opts def create_internal_results(net): """ @@ -383,8 +398,12 @@ def initialize_pit(net): comp.create_pit_node_entries(net, pit["node"]) comp.create_pit_branch_entries(net, pit["branch"]) comp.create_component_array(net, pit["components"]) - return pit["node"], pit["branch"] + if len(pit["node"]) == 0: + logger.warning("There are no nodes defined. " + "You need at least one node! " + "Without any nodes, you are not able to conduct a pipeflow!") + return def create_empty_pit(net): """ @@ -469,7 +488,7 @@ def create_lookups(net): "internal_nodes_lookup": internal_nodes_lookup} -def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): +def identify_active_nodes_branches(net, hydraulic=True): """ Function that creates the connectivity lookup for nodes and branches. If the option \ "check_connectivity" is set, a full connectivity check is performed based on a sparse matrix \ @@ -493,6 +512,10 @@ def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): :type hydraulic: bool, default True :return: No output """ + + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] + if hydraulic: # connectivity check for hydraulic simulation if get_net_option(net, "check_connectivity"): @@ -673,7 +696,7 @@ def get_table_index_list(net, pit_array, pit_indices, pit_type="node"): for tbl in tables] -def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): +def reduce_pit(net, mode="hydraulics"): """ Create an internal ("active") pit with all nodes and branches that are actually in_service. This is also done for different lookups (e.g. the from_to indices for this pit and the node index @@ -691,6 +714,10 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): :type mode: str, default "hydraulics" :return: No output """ + + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] + active_pit = dict() els = dict() reduced_node_lookup = None diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 5e277608f..0dfaa2c7a 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -2,7 +2,7 @@ from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MDOTINIT, RE, \ - LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA + LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA, TEXT from pandapipes.idx_node import TABLE_IDX as TABLE_IDX_NODE, PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option @@ -21,7 +21,7 @@ def extract_all_results(net, calculation_mode): :param net: pandapipes net for which to extract results into net.res_xy :type net: pandapipesNet - :param net: mode of the simulation (e.g. "hydraulics" or "heat" or "all") + :param net: mode of the simulation (e.g. "hydraulics" or "heat" or "sequential" or "bidirectional") :type net: str :return: No output @@ -182,7 +182,7 @@ def extract_branch_results_with_internals(net, branch_results, table_name, if result_mode == "hydraulics" and simulation_mode == "heat": continue lookup_name = "hydraulics" - if result_mode == "heat" and simulation_mode in ["heat", "all"]: + if result_mode == "heat" and simulation_mode in ["heat", "sequential", "bidirectional"]: lookup_name = "heat_transfer" comp_connected = get_lookup(net, "branch", "active_" + lookup_name)[f:t] for (res_ext, node_name) in ((res_nodes_from, "from_nodes"), (res_nodes_to, "to_nodes")): @@ -233,7 +233,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul :type required_results_heat: list[tuple] :param table_name: The name of the table that the results should be written to :type table_name: str - :param simulation_mode: simulation mode (e.g. "hydraulics", "heat", "all"); defines whether results from \ + :param simulation_mode: simulation mode (e.g. "hydraulics", "heat", "sequential", "bidirectional"); defines whether results from \ hydraulic or temperature calculation are transferred :type simulation_mode: str :return: No output @@ -243,7 +243,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul f, t = get_lookup(net, "branch", "from_to")[table_name] # extract hydraulic results - if simulation_mode in ["hydraulics", "all"]: + if simulation_mode in ["hydraulics", 'sequential', "bidirectional"]: # lookup for connected branch elements (hydraulic results) comp_connected_hyd = get_lookup(net, "branch", "active_hydraulics")[f:t] for res_name, entry in required_results_hydraulic: @@ -255,7 +255,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul branch_results[entry][f:t][comp_connected_hyd] # extract heat transfer results - if simulation_mode in ["heat", "all"]: + if simulation_mode in ["heat", 'sequential', "bidirectional"]: # lookup for connected branch elements (heat transfer results) comp_connected_ht = get_lookup(net, "branch", "active_heat_transfer")[f:t] for res_name, entry in required_results_heat: @@ -290,16 +290,19 @@ def extract_results_active_pit(net, mode="hydraulics"): not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] - net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN + amb = get_net_option(net, 'ambient_temperature') + + net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN if mode == "hydraulics" else amb net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN if mode == "hydraulics" else \ + net["_pit"]["branch"][~branches_connected, TEXT] net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols] def consider_heat(mode, results=None): - consider_ = mode in ["heat", "all"] + consider_ = mode in ["heat", 'sequential', 'bidirectional'] if results is None: return consider_ return consider_ and any(r[2] for r in results) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 629c1cd0f..1ef79d2ae 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -10,10 +10,9 @@ from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal -from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, \ - init_options, create_internal_results, write_internal_results, get_lookup, create_lookups, \ - initialize_pit, reduce_pit, set_user_pf_options, init_all_result_tables, \ - identify_active_nodes_branches, PipeflowNotConverged +from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, init_options, \ + create_internal_results, write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, \ + set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, PipeflowNotConverged from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit try: @@ -68,136 +67,147 @@ def pipeflow(net, sol_vec=None, **kwargs): init_all_result_tables(net) create_lookups(net) - node_pit, branch_pit = initialize_pit(net) - if len(node_pit) == 0: - logger.warning("There are no nodes defined. " - "You need at least one node! " - "Without any nodes, you are not able to conduct a pipeflow!") - return + initialize_pit(net) calculation_mode = get_net_option(net, "mode") - calculate_hydraulics = calculation_mode in ["hydraulics", "all"] - calculate_heat = calculation_mode in ["heat", "all"] + calculate_hydraulics = calculation_mode in ["hydraulics", 'sequential'] + calculate_heat = calculation_mode in ["heat", 'sequential'] + calculate_bidrect = calculation_mode == "bidirectional" # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also required to # determine the active node/branch heat transfer lookup - identify_active_nodes_branches(net, branch_pit, node_pit) - - if calculation_mode == "heat": - if not net.user_pf_options["hyd_flag"]: - raise UserWarning("Converged flag not set. Make sure that hydraulic calculation " - "results are available.") - else: - net["_pit"]["node"][:, PINIT] = sol_vec[:len(node_pit)] - net["_pit"]["branch"][:, MDOTINIT] = sol_vec[len(node_pit):] - - if calculate_hydraulics: - reduce_pit(net, node_pit, branch_pit, mode="hydraulics") - hydraulics(net) - if not net.converged: - raise PipeflowNotConverged("The hydraulic calculation did not converge to a solution.") - extract_results_active_pit(net, mode="hydraulics") - - if calculate_heat: - node_pit, branch_pit = net["_pit"]["node"], net["_pit"]["branch"] - identify_active_nodes_branches(net, branch_pit, node_pit, False) - reduce_pit(net, node_pit, branch_pit, mode="heat_transfer") - heat_transfer(net) - if not net.converged: - raise PipeflowNotConverged("The heat transfer calculation did not converge to a " - "solution.") - extract_results_active_pit(net, mode="heat_transfer") - elif not calculate_hydraulics: + identify_active_nodes_branches(net) + + if calculation_mode == 'heat': use_given_hydraulic_results(net, sol_vec) + + if not (calculate_hydraulics | calculate_heat | calculate_bidrect): raise UserWarning("No proper calculation mode chosen.") + elif calculate_bidrect: + bidirectional(net) + else: + if calculate_hydraulics: + hydraulics(net) + if calculate_heat: + heat_transfer(net) extract_all_results(net, calculation_mode) -def hydraulics(net): - max_iter, nonlinear_method, tol_p, tol_m, tol_res = get_net_options( - net, "max_iter_hyd", "nonlinear_method", "tol_p", "tol_m", "tol_res") +def use_given_hydraulic_results(net, sol_vec): + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] - # Start of nonlinear loop - # --------------------------------------------------------------------------------------------- - niter = 0 - create_internal_results(net) - if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: - net["_internal_data"] = dict() + if not net.user_pf_options["hyd_flag"]: + raise UserWarning("Converged flag not set. Make sure that hydraulic calculation " + "results are available.") + else: + node_pit[:, PINIT] = sol_vec[:len(node_pit)] + branch_pit[:, MDOTINIT] = sol_vec[len(node_pit):] - # This branch is used to stop the solver after a specified error tolerance is reached - error_m, error_p, residual_norm = [], [], None +def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): + max_iter, nonlinear_method, tol_res = get_net_options(net, iter_name, "nonlinear_method", "tol_res") + niter = 0 + # This branch is used to stop the solver after a specified error tolerance is reached + errors = {var: [] for var in vars} + diff = {var: [] for var in vars} + create_internal_results(net) + residual_norm = None # This loop is left as soon as the solver converged while not net.converged and niter < max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place - m_init, p_init, m_init_old, p_init_old, epsilon = solve_hydraulics(net) + results, residual = funct(net) + residual_norm = linalg.norm(residual / len(residual)) + logger.debug("residual: %s" % residual_norm.round(4)) + pos = np.arange(len(vars) * 2) + results = np.array(results, object) + vals_new = results[pos[::2]] + vals_old = results[pos[1::2]] + for var, val_new, val_old in zip(vars, vals_new, vals_old): + dval = val_new - val_old + diff[var].append(dval.mean()) + errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) + finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, + vals_old=vals_old, vars=vars, pit_names=pit_names, diff=diff) + niter += 1 + write_internal_results(net, **errors) + kwargs = dict() + kwargs['residual_norm_%s' % mode] = residual_norm + kwargs['iterations_%s' % mode] = niter + write_internal_results(net, **kwargs) + log_final_results(net, mode, niter, residual_norm, vars, tols) - # Error estimation & convergence plot - dm_init = np.abs(m_init - m_init_old) - dp_init = np.abs(p_init - p_init_old) - residual_norm = linalg.norm(epsilon) / len(epsilon) - error_m.append(linalg.norm(dm_init) / len(dm_init) if len(dm_init) else 0) - error_p.append(linalg.norm(dp_init / len(dp_init))) +def bidirectional(net): + if get_net_option(net, 'nonlinear_method') == 'std': + set_net_option(net, 'alpha', 0.33) + net.converged = False + if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: + net["_internal_data"] = dict() + vars = ['mdot', 'p', 'TOUT', 'T'] + tol_m, tol_p, tol_T = get_net_options(net, 'tol_m', 'tol_p', 'tol_T') + newton_raphson(net, solve_bidirectional, 'bidirectional', vars, [tol_m, tol_p, tol_T, tol_T], + ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect') + if net.converged: + set_user_pf_options(net, hyd_flag=True) + if not get_net_option(net, "reuse_internal_data"): + net.pop("_internal_data", None) + if not net.converged: + raise PipeflowNotConverged("The bidrectional calculation did not converge to a solution.") - finalize_iteration(net, niter, error_p, error_m, residual_norm, nonlinear_method, tol_p, - tol_m, tol_res, p_init_old, m_init_old) - niter += 1 - write_internal_results(net, iterations=niter, error_p=error_p[niter - 1], - error_m=error_m[niter - 1], residual_norm=residual_norm) +def hydraulics(net): + # Start of nonlinear loop + # --------------------------------------------------------------------------------------------- + net.converged = False + reduce_pit(net, mode="hydraulics") + if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: + net["_internal_data"] = dict() + vars = ['mdot', 'p'] + tol_p, tol_m = get_net_options(net, 'tol_m', 'tol_p') + newton_raphson(net, solve_hydraulics, 'hydraulics', vars, [tol_m, tol_p], ['branch', 'node'], 'max_iter_hyd') if net.converged: set_user_pf_options(net, hyd_flag=True) - log_final_results(net, niter, residual_norm) if not get_net_option(net, "reuse_internal_data"): net.pop("_internal_data", None) + if not net.converged: + raise PipeflowNotConverged("The hydraulic calculation did not converge to a solution.") + extract_results_active_pit(net, mode="hydraulics") + def heat_transfer(net): - max_iter, nonlinear_method, tol_t, tol_res = get_net_options( - net, "max_iter_therm", "nonlinear_method", "tol_T", "tol_res") - # Start of nonlinear loop # --------------------------------------------------------------------------------------------- - + net.converged = False + identify_active_nodes_branches(net, False) + reduce_pit(net, mode="heat_transfer") if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") + vars = ['Tout', 'Tin'] + tol_T = next(get_net_options(net, 'tol_T')) + newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['node', 'branch'], 'max_iter_therm') + if not net.converged: + raise PipeflowNotConverged("The heat transfer calculation did not converge to a " + "solution.") + extract_results_active_pit(net, mode="heat_transfer") - error_t, error_t_out, residual_norm = [], [], None - - net.converged = False - niter = 0 - - # This loop is left as soon as the solver converged - while not net.converged and niter < max_iter: - logger.debug("niter %d" % niter) - - # solve_hydraulics is where the calculation takes place - t_out, t_out_old, t_init, t_init_old, epsilon = solve_temperature(net) - - # Error estimation & convergence plot - delta_t_init = np.abs(t_init - t_init_old) - delta_t_out = np.abs(t_out - t_out_old) - - residual_norm = (linalg.norm(epsilon) / (len(epsilon))) - error_t.append(linalg.norm(delta_t_init) / (len(delta_t_init))) - error_t_out.append(linalg.norm(delta_t_out) / (len(delta_t_out))) - - finalize_iteration(net, niter, error_t, error_t_out, residual_norm, nonlinear_method, tol_t, - tol_t, tol_res, t_init_old, t_out_old, hydraulic_mode=False) - logger.debug("F: %s" % epsilon.round(4)) - logger.debug("T_init_: %s" % t_init.round(4)) - logger.debug("T_out_: %s" % t_out.round(4)) - niter += 1 - - write_internal_results(net, iterations_T=niter, error_T=error_t[niter - 1], - residual_norm_T=residual_norm) - log_final_results(net, niter, residual_norm, hyraulic_mode=False) +def solve_bidirectional(net): + reduce_pit(net, mode="hydraulics") + res_hyd, residual_hyd = solve_hydraulics(net) + extract_results_active_pit(net, mode="hydraulics") + identify_active_nodes_branches(net, False) + reduce_pit(net, mode="heat_transfer") + res_heat, residual_heat = solve_temperature(net) + extract_results_active_pit(net, mode="heat_transfer") + residual = np.concatenate([residual_hyd, residual_heat]) + res = res_hyd + res_heat + return res, residual def solve_hydraulics(net): @@ -217,22 +227,21 @@ def solve_hydraulics(net): branch_lookups = get_lookup(net, "branch", "from_to_active_hydraulics") for comp in net['component_list']: - comp.adaption_before_derivatives_hydraulic( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) calculate_derivatives_hydraulic(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_hydraulic( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) m_init_old = branch_pit[:, MDOTINIT].copy() p_init_old = node_pit[:, PINIT].copy() x = spsolve(jacobian, epsilon) + branch_pit[:, MDOTINIT] -= x[len(node_pit):] node_pit[:, PINIT] -= x[:len(node_pit)] * options["alpha"] - return branch_pit[:, MDOTINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon + return [branch_pit[:, MDOTINIT], m_init_old, node_pit[:, PINIT], p_init_old], epsilon def solve_temperature(net): @@ -264,25 +273,24 @@ def solve_temperature(net): branch_pit[mask, TO_NODE_T] = branch_pit[mask, FROM_NODE] for comp in net['component_list']: - comp.adaption_before_derivatives_thermal( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_thermal(net, branch_pit, node_pit, branch_lookups, options) calculate_derivatives_thermal(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_thermal( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_thermal(net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, True) t_init_old = node_pit[:, TINIT].copy() t_out_old = branch_pit[:, TOUTINIT].copy() x = spsolve(jacobian, epsilon) + node_pit[:, TINIT] += x[:len(node_pit)] * options["alpha"] branch_pit[:, TOUTINIT] += x[len(node_pit):] - return branch_pit[:, TOUTINIT], t_out_old, node_pit[:, TINIT], t_init_old, epsilon + return [branch_pit[:, TOUTINIT], t_out_old, node_pit[:, TINIT], t_init_old], epsilon -def set_damping_factor(net, niter, error): +def set_damping_factor(net, niter, errors): """ Set the value of the damping factor (factor for the newton step width) from current results. @@ -296,67 +304,50 @@ def set_damping_factor(net, niter, error): EXAMPLE: set_damping_factor(net, niter, [error_p, error_v]) """ - error_x0 = error[0] - error_x1 = error[1] - - error_x0_increased = error_x0[niter] > error_x0[niter - 1] - error_x1_increased = error_x1[niter] > error_x1[niter - 1] + error_increased = [] + for error in errors.values(): + error_increased.append(error[niter] > error[niter - 1]) current_alpha = get_net_option(net, "alpha") - - if error_x0_increased and error_x1_increased: + if np.all(error_increased): set_net_option(net, "alpha", current_alpha / 10 if current_alpha >= 0.1 else current_alpha) else: set_net_option(net, "alpha", current_alpha * 10 if current_alpha <= 0.1 else 1.0) - - return error_x0_increased, error_x1_increased + return error_increased -def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_method, tol_1, tol_2, - tol_res, vals_1_old, vals_2_old, hydraulic_mode=True): - col1, col2 = (PINIT, MDOTINIT) if hydraulic_mode else (TINIT, TOUTINIT) - +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names, + diff): # Control of damping factor if nonlinear_method == "automatic": - error_x0_increased, error_x1_increased = set_damping_factor(net, niter, - [error_1, error_2]) - if error_x0_increased: - net["_active_pit"]["node"][:, col1] = vals_1_old - if error_x1_increased: - net["_active_pit"]["branch"][:, col2] = vals_2_old + errors_increased = set_damping_factor(net, niter, errors) + logger.debug("alpha: %s" % get_net_option(net, "alpha")) + for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): + if error_increased: + net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val + if get_net_option(net, "alpha") != 1: + net.converged = False + return + elif nonlinear_method == "std": + max_std = np.std(list(diff.values()), axis=1)[:5].max() + alpha = 0.33 if max_std == 0 else 1 if max_std < 1 else 0.33 if max_std > 3 else 1 / max_std + set_net_option(net, "alpha", alpha) elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") - - # Setting convergence flag - if error_2[niter] <= tol_2 and error_1[niter] <= tol_1 and residual_norm < tol_res: - if nonlinear_method != "automatic": - net.converged = True - elif get_net_option(net, "alpha") == 1: - net.converged = True - - if hydraulic_mode: - logger.debug("errorv: %s" % error_1[niter]) - logger.debug("errorp: %s" % error_2[niter]) - logger.debug("alpha: %s" % get_net_option(net, "alpha")) - else: - logger.debug("errorT: %s" % error_1[niter]) - logger.debug("alpha: %s" % get_net_option(net, "alpha")) + for error, var, tol in zip(errors.values(), vars, tols): + converged = error[niter] <= tol + if not converged: break + logger.debug("error_%s: %s" % (var, error[niter])) + net.converged = converged and residual_norm <= tol_res -def log_final_results(net, niter, residual_norm, hyraulic_mode=True): - if hyraulic_mode: - solver = "hydraulics" - outputs = ["tol_p", "tol_m"] - else: - solver = "heat transfer" - outputs = ["tol_T"] +def log_final_results(net, solver, niter, residual_norm, vars, tols): logger.debug("--------------------------------------------------------------------------------") if not net.converged: - logger.debug("Maximum number of iterations reached but %s solver did not converge." - % solver) + logger.debug("Maximum number of iterations reached but %s solver did not converge." % solver) logger.debug("Norm of residual: %s" % residual_norm) else: logger.debug("Calculation completed. Preparing results...") logger.debug("Converged after %d iterations." % niter) logger.debug("Norm of residual: %s" % residual_norm) - for out in outputs: - logger.debug("%s: %s" % (out, get_net_option(net, out))) + for var, tol in zip(vars, tols): + logger.debug("tolerance for %s: %s" % (var, tol)) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index 51ff4943c..59988e2d7 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -38,7 +38,7 @@ def test_circulation_pump_constant_mass(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_mass.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index bb24286f2..925eea905 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -39,7 +39,7 @@ def test_circulation_pump_constant_pressure(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index a78edc713..a334b4fb2 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -98,7 +98,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -119,7 +119,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -161,7 +161,7 @@ def test_t_type_tee(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -187,7 +187,7 @@ def test_t_type_tee(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values temp_diff = np.abs(1 - temp / temp2) @@ -231,7 +231,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -261,7 +261,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -305,7 +305,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -335,7 +335,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -381,7 +381,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -411,7 +411,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values diff --git a/src/pandapipes/test/api/test_components/test_flow_control.py b/src/pandapipes/test/api/test_components/test_flow_control.py index 026532d59..6afc39fdf 100644 --- a/src/pandapipes/test/api/test_components/test_flow_control.py +++ b/src/pandapipes/test/api/test_components/test_flow_control.py @@ -28,7 +28,7 @@ def test_flow_control_simple_heat(use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values, [2, 1]) @@ -37,7 +37,7 @@ def test_flow_control_simple_heat(use_numba): pandapipes.create_flow_control(net, j_new[0], j_new[1], 2, 0.1) pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba, check_connectivity=True) + mode='sequential', use_numba=use_numba, check_connectivity=True) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values[:2], [2, 1]) diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 491a117a5..23e2ce28a 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -6,8 +6,8 @@ import pytest import pandapipes -import pandas as pd import numpy as np +import pytest MDOT = [3, 2] @@ -17,6 +17,7 @@ @pytest.fixture(scope="module") def simple_heat_net(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, system=["flow"] * 3 + ["return"] * 3) pandapipes.create_pipes_from_parameters( @@ -36,12 +37,12 @@ def test_heat_consumer_equivalence(simple_heat_net): controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) - pandapipes.pipeflow(net, mode="all") + pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) - pandapipes.pipeflow(net2, mode="all") + pandapipes.pipeflow(net2, mode='sequential') assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) @@ -53,45 +54,72 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, qext_w=QEXT) - pandapipes.pipeflow(net, mode="all") + pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) - pandapipes.pipeflow(net2, mode="all") + pandapipes.pipeflow(net2, mode='sequential') assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) +def test_heat_consumer_equivalence2(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") -def test_heat_consumer_not_implemented_model(simple_heat_net): - net = copy.deepcopy(simple_heat_net) - juncs = net.junction.index + mdot = [3, 3] + qext = [150000, 75000] - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], deltat_k=20) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], - deltat_k=20) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], treturn_k=390) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], - treturn_k=390) - - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - deltat_k=[20, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - treturn_k=[390, None]) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, + system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters( + net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, + system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 + ) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + + net2 = copy.deepcopy(net) + net3 = copy.deepcopy(net) + net4 = copy.deepcopy(net) + net5 = copy.deepcopy(net) + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + qext_w=qext[1]) + pandapipes.pipeflow(net, mode="bidirectional") + + pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, + qext_w=qext[1]) + pandapipes.pipeflow(net2, mode="bidirectional", iter=40, nonlinear_method='std') + + pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=5.9673377831196035, + qext_w=qext[1]) + pandapipes.pipeflow(net3, mode="bidirectional") + + pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net4, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + treturn_k= 285.4461399735642) + pandapipes.pipeflow(net4, mode="bidirectional") + + pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net5, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + deltat_k=5.9673377831196035) + pandapipes.pipeflow(net5, mode="bidirectional") + + assert np.allclose(net2.res_junction, net.res_junction) + assert np.allclose(net2.res_pipe, net.res_pipe) + assert np.allclose(net3.res_junction, net.res_junction) + assert np.allclose(net3.res_pipe, net.res_pipe) + assert np.allclose(net4.res_junction, net.res_junction) + assert np.allclose(net4.res_pipe, net.res_pipe) + assert np.allclose(net5.res_junction, net.res_junction) + assert np.allclose(net5.res_pipe, net.res_pipe) def test_heat_consumer_creation_not_allowed(simple_heat_net): diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index d485cf901..fbb27f067 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -33,7 +33,7 @@ def test_heat_exchanger(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "heat_exchanger_test.csv"), sep=';', diff --git a/src/pandapipes/test/api/test_time_series.py b/src/pandapipes/test/api/test_time_series.py index b565cbaae..2045ec107 100644 --- a/src/pandapipes/test/api/test_time_series.py +++ b/src/pandapipes/test/api/test_time_series.py @@ -13,9 +13,9 @@ def person_run_fct(net, sol_vec=None, **kwargs): net = ntw.water_strand_net_2pumps() max_iter_hyd = 3 max_iter_therm = 1 - pps.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + pps.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) assert all(np.isclose(net.res_junction.p_bar.values, [7., 25.02309542, 24.73038636, 22.11851835, 16.70728061, 16.23637491])) run_timeseries(net, time_steps=range(10), max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode='all', run=person_run_fct) + mode='sequential', run=person_run_fct) assert all(net.output_writer.iat[0, 0].np_results['res_junction.p_bar'].flatten() == 15.) diff --git a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py index 03c7ab523..74c9f5bf7 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py @@ -28,7 +28,7 @@ def test_case_delta(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.05) assert np.all(v_diff_abs < 0.05) @@ -42,7 +42,7 @@ def test_case_delta_2sinks(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -56,7 +56,7 @@ def test_case_heights(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.0065) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -70,7 +70,7 @@ def test_case_one_pipe(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -84,7 +84,7 @@ def test_case_one_source(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.04) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -98,7 +98,7 @@ def test_case_section_variation(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) # all values of temp_diff_mean are zero except one with about 0.025 assert np.all(temp_diff_mean < 0.03) assert np.all(p_diff < 0.022) @@ -113,7 +113,7 @@ def test_case_t_cross(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -127,7 +127,7 @@ def test_case_two_pipes(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 29ba322fe..b252ddda1 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -306,7 +306,7 @@ def test_connectivity_heat1(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 3 if use_numba else 3 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) oos_juncs_hyd = {4, 5, 6, 7} oos_pipe_hyd = {5, 7, 8, 9} @@ -346,7 +346,7 @@ def test_connectivity_heat2(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 5 if use_numba else 5 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == {4} assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -379,7 +379,7 @@ def test_connectivity_heat3(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == set() assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -415,9 +415,9 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 9 if use_numba else 9 max_iter_therm = 6 if use_numba else 6 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) pandapipes.pipeflow(net2, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=False, use_numba=use_numba) + mode='sequential', check_connectivity=False, use_numba=use_numba) assert pandapipes.nets_equal(net, net2, check_only_results=True) @@ -439,11 +439,11 @@ def test_connectivity_heat5(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 9 if use_numba else 9 max_iter_therm = 3 if use_numba else 3 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - check_connectivity=True, mode='all', use_numba=use_numba) + check_connectivity=True, mode='sequential', use_numba=use_numba) with pytest.raises(PipeflowNotConverged): pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - check_connectivity=False, mode='all', use_numba=use_numba) + check_connectivity=False, mode='sequential', use_numba=use_numba) @pytest.mark.parametrize("use_numba", [True, False]) @@ -669,7 +669,7 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): assert net.converged with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index 416ac7de2..59b42f7c7 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -84,29 +84,29 @@ def test_iter(create_test_net, use_numba): pandapipes.set_user_pf_options(net, iter=2) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.pipeflow(net, mode='hydraulics', max_iter_hyd=max_iter_hyd) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd) + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd) - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd) pandapipes.pipeflow(net, mode='hydraulics') with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.set_user_pf_options(net, max_iter_therm=max_iter_therm) - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', iter=2) + pandapipes.pipeflow(net, mode='sequential', iter=2) if __name__ == '__main__': diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 44d85e71f..389e7c6f8 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -95,7 +95,7 @@ def test_temperature_internal_nodes_single_pipe(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) pipe_results = Pipe.get_internal_results(net, [0]) @@ -150,7 +150,7 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), @@ -193,7 +193,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), @@ -236,7 +236,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), @@ -279,7 +279,7 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), sep=';', @@ -324,7 +324,7 @@ def test_temperature_internal_nodes_masche_1load(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_an.csv"), @@ -366,7 +366,7 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index c982dd8b4..e86e9f30e 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -86,7 +86,7 @@ def test_heat_only(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - nonlinear_method="automatic", mode="all", use_numba=use_numba) + nonlinear_method="automatic", mode='sequential', use_numba=use_numba) ntw = pandapipes.create_empty_network("net") d = 75e-3 diff --git a/src/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py index 9d8193e49..27111a3a1 100644 --- a/src/pandapipes/test/test_toolbox.py +++ b/src/pandapipes/test/test_toolbox.py @@ -264,7 +264,6 @@ def test_select_subnet(base_net_is_wo_pumps): assert len(net2["res_" + comp.table_name()]) == len(net2[comp.table_name()]) assert len(net.junction) == len(net2.junction) + 3 - def test_pit_extraction(): max_ver = max(found_versions) if version.parse(max_ver) >= version.parse(minimal_version_two_nets): diff --git a/tutorials/circular_flow_in_a_district_heating_grid.ipynb b/tutorials/circular_flow_in_a_district_heating_grid.ipynb index a06e23669..07ba52de4 100644 --- a/tutorials/circular_flow_in_a_district_heating_grid.ipynb +++ b/tutorials/circular_flow_in_a_district_heating_grid.ipynb @@ -131,7 +131,7 @@ "metadata": {}, "outputs": [], "source": [ - "pp.pipeflow(net, mode='all')" + "pp.pipeflow(net, mode='sequential')" ] }, { From b1b987e29219c60ad10ceb70ea2d46f824b8544f Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 19 Apr 2024 14:16:16 +0200 Subject: [PATCH 152/237] extraction of vdot now based on real density for incompressible media --- src/pandapipes/pf/result_extraction.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 5e277608f..5ffe01d37 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -7,6 +7,7 @@ from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option from pandapipes.properties.fluids import get_fluid +from pandapipes.properties.properties_toolbox import get_branch_real_density try: from numba import jit @@ -57,11 +58,14 @@ def extract_all_results(net, calculation_mode): def get_basic_branch_results(net, branch_pit, node_pit): from_nodes = branch_pit[:, FROM_NODE].astype(np.int32) to_nodes = branch_pit[:, TO_NODE].astype(np.int32) - fluid = get_fluid(net) t0 = node_pit[from_nodes, TINIT_NODE] t1 = node_pit[to_nodes, TINIT_NODE] - vf = branch_pit[:, MDOTINIT] / get_fluid(net).get_density(NORMAL_TEMPERATURE) - v = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] + fluid = get_fluid(net) + if fluid.is_gas: + vf = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) + else: + vf = branch_pit[:, MDOTINIT] / get_branch_real_density(net, branch_pit, node_pit) + v = vf / branch_pit[:, AREA] return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ branch_pit[:, PL] From 6398261df96e86cad8f4c17326317f25569918bb Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 19 Apr 2024 14:22:41 +0200 Subject: [PATCH 153/237] fixed argument order of call --- src/pandapipes/pf/result_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 5ffe01d37..270e885ec 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -64,7 +64,7 @@ def get_basic_branch_results(net, branch_pit, node_pit): if fluid.is_gas: vf = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) else: - vf = branch_pit[:, MDOTINIT] / get_branch_real_density(net, branch_pit, node_pit) + vf = branch_pit[:, MDOTINIT] / get_branch_real_density(net, node_pit, branch_pit) v = vf / branch_pit[:, AREA] return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ From 088072bd4254b97269e85f1ba140657e7c6883a3 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Fri, 19 Apr 2024 14:23:26 +0200 Subject: [PATCH 154/237] another wrong argument --- src/pandapipes/pf/result_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 270e885ec..665fd2720 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -64,7 +64,7 @@ def get_basic_branch_results(net, branch_pit, node_pit): if fluid.is_gas: vf = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) else: - vf = branch_pit[:, MDOTINIT] / get_branch_real_density(net, node_pit, branch_pit) + vf = branch_pit[:, MDOTINIT] / get_branch_real_density(fluid, node_pit, branch_pit) v = vf / branch_pit[:, AREA] return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ From 5c6c8709733848fad033cb07202e594331c39772 Mon Sep 17 00:00:00 2001 From: SRDM Date: Sat, 20 Apr 2024 21:56:08 +0200 Subject: [PATCH 155/237] avoiding one-line if-conditions --- src/pandapipes/pipeflow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 1ef79d2ae..462e7d543 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -78,7 +78,8 @@ def pipeflow(net, sol_vec=None, **kwargs): # determine the active node/branch heat transfer lookup identify_active_nodes_branches(net) - if calculation_mode == 'heat': use_given_hydraulic_results(net, sol_vec) + if calculation_mode == 'heat': + use_given_hydraulic_results(net, sol_vec) if not (calculate_hydraulics | calculate_heat | calculate_bidrect): raise UserWarning("No proper calculation mode chosen.") From 52c47c89230f0ca355512d3cbb60bff1c2e36959 Mon Sep 17 00:00:00 2001 From: SRDM Date: Sun, 21 Apr 2024 00:21:42 +0200 Subject: [PATCH 156/237] std method not working, removed --- src/pandapipes/pipeflow.py | 19 ++++++------------- .../api/test_components/test_heat_consumer.py | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 462e7d543..8b25a98a8 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -111,7 +111,6 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): niter = 0 # This branch is used to stop the solver after a specified error tolerance is reached errors = {var: [] for var in vars} - diff = {var: [] for var in vars} create_internal_results(net) residual_norm = None # This loop is left as soon as the solver converged @@ -128,10 +127,9 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): vals_old = results[pos[1::2]] for var, val_new, val_old in zip(vars, vals_new, vals_old): dval = val_new - val_old - diff[var].append(dval.mean()) errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, - vals_old=vals_old, vars=vars, pit_names=pit_names, diff=diff) + vals_old=vals_old, vars=vars, pit_names=pit_names) niter += 1 write_internal_results(net, **errors) kwargs = dict() @@ -142,8 +140,6 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): def bidirectional(net): - if get_net_option(net, 'nonlinear_method') == 'std': - set_net_option(net, 'alpha', 0.33) net.converged = False if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() @@ -189,9 +185,9 @@ def heat_transfer(net): if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") - vars = ['Tout', 'Tin'] + vars = ['Tout', 'T'] tol_T = next(get_net_options(net, 'tol_T')) - newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['node', 'branch'], 'max_iter_therm') + newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['branch', 'node'], 'max_iter_therm') if not net.converged: raise PipeflowNotConverged("The heat transfer calculation did not converge to a " "solution.") @@ -316,22 +312,19 @@ def set_damping_factor(net, niter, errors): return error_increased -def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names, - diff): +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names): # Control of damping factor if nonlinear_method == "automatic": errors_increased = set_damping_factor(net, niter, errors) logger.debug("alpha: %s" % get_net_option(net, "alpha")) for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): if error_increased: + # todo: not working in bidirectional mode as bidirectional is not distinguishing between \ + # hydraulics and heat transfer active pit net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val if get_net_option(net, "alpha") != 1: net.converged = False return - elif nonlinear_method == "std": - max_std = np.std(list(diff.values()), axis=1)[:5].max() - alpha = 0.33 if max_std == 0 else 1 if max_std < 1 else 0.33 if max_std > 3 else 1 / max_std - set_net_option(net, "alpha", alpha) elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") for error, var, tol in zip(errors.values(), vars, tols): diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 23e2ce28a..ec0342ae4 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -92,7 +92,7 @@ def test_heat_consumer_equivalence2(): qext_w=qext[0]) pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, qext_w=qext[1]) - pandapipes.pipeflow(net2, mode="bidirectional", iter=40, nonlinear_method='std') + pandapipes.pipeflow(net2, mode="bidirectional", iter=20, alpha=0.65) pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) From 7cd13e850ba0b755ca510e9d747d48c0daa0d95a Mon Sep 17 00:00:00 2001 From: hkoertge Date: Thu, 25 Apr 2024 11:01:55 +0200 Subject: [PATCH 157/237] switched from setup.py to pyproject.toml added change to CHANGELOG.rst version in __init__.py and doc/source/conf.py is now read from pyproject.toml removed content of setup.py removed calls to setup.py in workflows as calling setup.py directly is deprecated --- .github/workflows/release.yml | 11 +++--- CHANGELOG.rst | 6 ++++ doc/source/conf.py | 11 ++++-- pyproject.toml | 65 +++++++++++++++++++++++++++++++++++ setup.py | 54 ++--------------------------- src/pandapipes/__init__.py | 4 ++- 6 files changed, 90 insertions(+), 61 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71bafbf41..423f571a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,14 +38,14 @@ jobs: # Upgrade pip python3 -m pip install --upgrade pip # Install twine - python3 -m pip install setuptools wheel twine + python3 -m pip install build setuptools wheel twine # Upload to TestPyPI - name: Build and Upload to TestPyPI if: ${{ inputs.upload_server == 'testpypi'}} run: | - python3 setup.py sdist --formats=zip - twine check dist/* --strict + python3 -m build + python3 -m twine check dist/* --strict python3 -m twine upload dist/* env: TWINE_USERNAME: __token__ @@ -56,8 +56,8 @@ jobs: - name: Build and Upload to PyPI if: ${{ inputs.upload_server == 'pypi' }} run: | - python3 setup.py sdist --formats=zip - twine check dist/* --strict + python3 -m build + python3 -m twine check dist/* --strict python3 -m twine upload dist/* env: TWINE_USERNAME: __token__ @@ -70,7 +70,6 @@ jobs: time: 300s build: - runs-on: ${{ matrix.os }} needs: upload strategy: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3e79f9eb2..c485275e1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Change Log ============= +[latest] - RELEASEDATE +------------------------------- + +- [CHANGED] switched from setup.py to pyproject.toml + + [0.10.0] - 2024-04-09 ------------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py index 31072d076..687461711 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,6 +12,7 @@ # import os import sys +from sphinx_pyproject import SphinxConfig sys.path.append(os.path.abspath('..')) sys.path.append(os.path.abspath('../..')) @@ -20,9 +21,13 @@ master_doc = 'index' + +# load pyproject.toml configuration +config = SphinxConfig("../../pyproject.toml") + # -- Project information ----------------------------------------------------- -project = 'pandapipes' +project = config.name copyright = '2020-2024 by Fraunhofer Institute for Energy Economics \ and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.' @@ -47,9 +52,9 @@ # built documents. # # The short X.Y version. -version = "0.10" +version = config.version.rsplit(".", 1)[0] # The full version, including alpha/beta/rc tags. -release = "0.10.0" +release = config.version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..b9a698c75 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +requires = ["build", "wheel", "setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "pandapipes" +version = "0.10.0" # File format version '__format_version__' is tracked in __init__.py +authors=[ + { name = "Simon Ruben Drauz-Mauel", email = "simon.ruben.drauz-mauel@iee.fraunhofer.de" }, + { name = "Daniel Lohmeier", email = "daniel.lohmeier@retoflow.de" }, + { name = "Jolando Marius Kisse", email = "jolando.kisse@uni-kassel.de" } +] +description = "A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + # Add the specific Python versions supported here, e.g.: + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12" +] +dependencies = [ + "pandapower ~= 2.14.6", + "matplotlib", + "shapely", +] +keywords = [ + "network", "analysis", "optimization", "automation", "grid", "energy", "engineering", "simulation", "pipeflow", "pandapipes", "gas" +] + +[project.urls] +Homepage = "https://www.pandapipes.org" +Documentation = "https://pandapipes.readthedocs.io" +Source = "https://github.com/e2nIEE/pandapipes" +Repository = "https://github.com/e2nIEE/pandapipes.git" +Issues = "https://github.com/e2nIEE/pandapipes/issues" +Download = "https://pypi.org/project/pandapipes/#files" +Changelog = "https://github.com/e2nIEE/pandapipes/blob/develop/CHANGELOG.rst" + +[project.optional-dependencies] +docs = ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "sphinx-pyproject"] +plotting = ["plotly", "igraph"] +test = ["pytest", "pytest-xdist", "nbmake"] +all = [ + "numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", + "plotly", "igraph", + "pytest", "pytest-xdist", "nbmake" +] + +[tool.setuptools.packages.find] +where = ["src"] +include = ["pandapipes*"] diff --git a/setup.py b/setup.py index b29abc6eb..c44eaf35e 100644 --- a/setup.py +++ b/setup.py @@ -1,57 +1,9 @@ +# -*- coding: utf-8 -*- + # Copyright (c) 2020-2024 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 re - -from setuptools import find_namespace_packages from setuptools import setup -with open('README.rst', 'rb') as f: - install = f.read().decode('utf-8') - -with open('CHANGELOG.rst', 'rb') as f: - changelog = f.read().decode('utf-8') - -classifiers = [ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3'] - -with open('.github/workflows/run_tests_master.yml', 'rb') as f: - lines = f.read().decode('utf-8') - versions = set(re.findall('3.[8-9]', lines)) | set(re.findall('3.1[0-9]', lines)) - for version in versions: - classifiers.append('Programming Language :: Python :: %s' % version) - -long_description = '\n\n'.join((install, changelog)) - -setup( - name='pandapipes', - version='0.10.0', - author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', - author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' - 'jolando.kisse@uni-kassel.de', - description='A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids', - long_description=long_description, - long_description_content_type='text/x-rst', - url='http://www.pandapipes.org', - license='BSD', - install_requires=["pandapower>=2.14.6", "matplotlib", "shapely"], - extras_require={"docs": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex"], - "plotting": ["plotly", "igraph"], - "test": ["pytest", "pytest-xdist", "nbmake"], - "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", - "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(where='src'), - package_dir={"": "src"}, - include_package_data=True, - classifiers=classifiers -) +setup() diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index f8e6f2dec..d542f1752 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -2,7 +2,9 @@ # 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. -__version__ = '0.10.0' +import importlib.metadata + +__version__ = importlib.metadata.version("pandapipes") __format_version__ = '0.10.0' import pandas as pd From 8602dd111fd4cdc818c62649e97029ca3ed28294 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 7 May 2024 06:55:29 +0200 Subject: [PATCH 158/237] fix failing tests due to hard coded pandapower geojson implementation not converted to pandapipes --- .../valve_pipe_plotting.py | 8 +-- src/pandapipes/create.py | 20 ++++++- src/pandapipes/plotting/collections.py | 8 +-- src/pandapipes/plotting/plotting_toolbox.py | 52 ++++++++++++++++++- 4 files changed, 78 insertions(+), 10 deletions(-) diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py index 16592eda6..1711413d9 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py @@ -6,11 +6,11 @@ import numpy as np import pandas as pd -from pandapower.plotting.collections import _create_complex_branch_collection, \ - add_cmap_to_collection, coords_from_node_geodata -from pandapower.plotting.plotting_toolbox import get_index_array - from pandapipes.plotting.patch_makers import valve_patches +from pandapipes.plotting.plotting_toolbox import coords_from_node_geodata +from pandapower.plotting.collections import (_create_complex_branch_collection, + add_cmap_to_collection) +from pandapower.plotting.plotting_toolbox import get_index_array try: import pandaplan.core.pplog as logging diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index bf05b253a..f7dc2651f 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,9 +4,10 @@ import numpy as np import pandas as pd +from pandapower.auxiliary import _preserve_dtypes from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ - _add_multiple_branch_geodata, _check_branch_element, _check_multiple_branch_elements + _check_branch_element, _check_multiple_branch_elements from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \ HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, \ @@ -1821,6 +1822,23 @@ def _check_std_type(net, std_type, table, function_name): 'one' % (std_type, table)) +def _add_multiple_branch_geodata(net, table, geodata, index): + geo_table = f"{table}_geodata" + dtypes = net[geo_table].dtypes + df = pd.DataFrame(index=index, columns=net[geo_table].columns) + # works with single or multiple lists of coordinates + if len(geodata[0]) == 2 and not hasattr(geodata[0][0], "__iter__"): + # geodata is a single list of coordinates + df["coords"] = [geodata] * len(index) + else: + # geodata is multiple lists of coordinates + df["coords"] = geodata + + net[geo_table] = pd.concat([net[geo_table],df], sort=False) + + _preserve_dtypes(net[geo_table], dtypes) + + ALLOWED_EG_TYPES = ["auto", "t", "p", "pt", "tp"] diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index 144b64d63..d7c5c96a1 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -4,12 +4,12 @@ import numpy as np import pandas as pd -from pandapower.plotting.collections import _create_node_collection, \ - _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection, \ - add_cmap_to_collection, coords_from_node_geodata -from pandapower.plotting.patch_makers import load_patches, ext_grid_patches from pandapipes.plotting.patch_makers import valve_patches, source_patches, heat_exchanger_patches, \ pump_patches, pressure_control_patches, compressor_patches, flow_control_patches +from pandapipes.plotting.plotting_toolbox import coords_from_node_geodata +from pandapower.plotting.collections import _create_node_collection, add_cmap_to_collection, \ + _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection +from pandapower.plotting.patch_makers import load_patches, ext_grid_patches from pandapower.plotting.plotting_toolbox import get_index_array try: diff --git a/src/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py index 23b5817ec..226725cc1 100644 --- a/src/pandapipes/plotting/plotting_toolbox.py +++ b/src/pandapipes/plotting/plotting_toolbox.py @@ -2,6 +2,15 @@ # 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 +try: + import pandaplan.core.pplog as logging +except ImportError: + import logging + +logger = logging.getLogger(__name__) + + def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1.0, source_size=1.0, valve_size=2.0, pump_size=1.0, heat_exchanger_size=1.0, pressure_control_size=1.0, compressor_size=1.0, flow_control_size=1.0): @@ -10,7 +19,7 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. geocoord so that the collections fit the plot nicely .. note: This is implemented because if you would choose a fixed values (e.g.\ - junction_size = 0.2), the size could be to small for large networks and vice versa + junction_size = 0.2), the size could be too small for large networks and vice versa :param net: pandapower network for which to create plot :type net: pandapowerNet @@ -46,3 +55,44 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. return sizes + +def coords_from_node_geodata(element_indices, from_nodes, to_nodes, node_geodata, table_name, + node_name="Bus", ignore_zero_length=True): + """ + Auxiliary function to get the node coordinates for a number of branches with respective from + and to nodes. The branch elements for which there is no geodata available are not included in + the final list of coordinates. + + :param element_indices: Indices of the branch elements for which to find node geodata + :type element_indices: iterable + :param from_nodes: Indices of the starting nodes + :type from_nodes: iterable + :param to_nodes: Indices of the ending nodes + :type to_nodes: iterable + :param node_geodata: Dataframe containing x and y coordinates of the nodes + :type node_geodata: pd.DataFrame + :param table_name: Name of the table that the branches belong to (only for logging) + :type table_name: str + :param node_name: Name of the node type (only for logging) + :type node_name: str, default "Bus" + :param ignore_zero_length: States if branches should be left out, if their length is zero, i.e.\ + from_node_coords = to_node_coords + :type ignore_zero_length: bool, default True + :return: Return values are:\ + - coords (list) - list of branch coordinates of shape (N, (2, 2))\ + - elements_with_geo (set) - the indices of branch elements for which coordinates wer found\ + in the node geodata table + """ + have_geo = np.isin(from_nodes, node_geodata.index.values) \ + & np.isin(to_nodes, node_geodata.index.values) + elements_with_geo = np.array(element_indices)[have_geo] + fb_with_geo, tb_with_geo = from_nodes[have_geo], to_nodes[have_geo] + coords = [[(x_from, y_from), (x_to, y_to)] for x_from, y_from, x_to, y_to + in np.concatenate([node_geodata.loc[fb_with_geo, ["x", "y"]].values, + node_geodata.loc[tb_with_geo, ["x", "y"]].values], axis=1) + if not ignore_zero_length or not (x_from == x_to and y_from == y_to)] + elements_without_geo = set(element_indices) - set(elements_with_geo) + if len(elements_without_geo) > 0: + logger.warning("No coords found for %s %s. %s geodata is missing for those %s!" + % (table_name + "s", elements_without_geo, node_name, table_name + "s")) + return coords, elements_with_geo From 5c650227955e06c51c4aa4c187d567db6f992f09 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 13 May 2024 08:33:13 +0200 Subject: [PATCH 159/237] some pep --- src/pandapipes/pipeflow.py | 88 +++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 8b25a98a8..a2f9d0fe8 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -6,13 +6,18 @@ from numpy import linalg from scipy.sparse.linalg import spsolve -from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, MDOTINIT_T +from pandapipes.idx_branch import (FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, + MDOTINIT_T) from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix -from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal -from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, init_options, \ - create_internal_results, write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, \ - set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, PipeflowNotConverged +from pandapipes.pf.derivative_calculation import (calculate_derivatives_hydraulic, + calculate_derivatives_thermal) +from pandapipes.pf.pipeflow_setup import ( + get_net_option, get_net_options, set_net_option, init_options, create_internal_results, + write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, + set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, + PipeflowNotConverged +) from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit try: @@ -74,8 +79,8 @@ def pipeflow(net, sol_vec=None, **kwargs): calculate_heat = calculation_mode in ["heat", 'sequential'] calculate_bidrect = calculation_mode == "bidirectional" - # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also required to - # determine the active node/branch heat transfer lookup + # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also + # required to determine the active node/branch heat transfer lookup identify_active_nodes_branches(net) if calculation_mode == 'heat': @@ -106,11 +111,13 @@ def use_given_hydraulic_results(net, sol_vec): branch_pit[:, MDOTINIT] = sol_vec[len(node_pit):] -def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): - max_iter, nonlinear_method, tol_res = get_net_options(net, iter_name, "nonlinear_method", "tol_res") +def newton_raphson(net, funct, mode, solver_vars, tols, pit_names, iter_name): + max_iter, nonlinear_method, tol_res = get_net_options( + net, iter_name, "nonlinear_method", "tol_res" + ) niter = 0 # This branch is used to stop the solver after a specified error tolerance is reached - errors = {var: [] for var in vars} + errors = {var: [] for var in solver_vars} create_internal_results(net) residual_norm = None # This loop is left as soon as the solver converged @@ -121,32 +128,36 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): results, residual = funct(net) residual_norm = linalg.norm(residual / len(residual)) logger.debug("residual: %s" % residual_norm.round(4)) - pos = np.arange(len(vars) * 2) + pos = np.arange(len(solver_vars) * 2) results = np.array(results, object) vals_new = results[pos[::2]] vals_old = results[pos[1::2]] - for var, val_new, val_old in zip(vars, vals_new, vals_old): + for var, val_new, val_old in zip(solver_vars, vals_new, vals_old): dval = val_new - val_old errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) - finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, - vals_old=vals_old, vars=vars, pit_names=pit_names) + finalize_iteration( + net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, + vals_old=vals_old, solver_vars=solver_vars, pit_names=pit_names + ) niter += 1 write_internal_results(net, **errors) kwargs = dict() kwargs['residual_norm_%s' % mode] = residual_norm kwargs['iterations_%s' % mode] = niter write_internal_results(net, **kwargs) - log_final_results(net, mode, niter, residual_norm, vars, tols) + log_final_results(net, mode, niter, residual_norm, solver_vars, tols) def bidirectional(net): net.converged = False if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() - vars = ['mdot', 'p', 'TOUT', 'T'] + solver_vars = ['mdot', 'p', 'TOUT', 'T'] tol_m, tol_p, tol_T = get_net_options(net, 'tol_m', 'tol_p', 'tol_T') - newton_raphson(net, solve_bidirectional, 'bidirectional', vars, [tol_m, tol_p, tol_T, tol_T], - ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect') + newton_raphson( + net, solve_bidirectional, 'bidirectional', solver_vars, [tol_m, tol_p, tol_T, tol_T], + ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect' + ) if net.converged: set_user_pf_options(net, hyd_flag=True) if not get_net_option(net, "reuse_internal_data"): @@ -162,9 +173,10 @@ def hydraulics(net): reduce_pit(net, mode="hydraulics") if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() - vars = ['mdot', 'p'] + solver_vars = ['mdot', 'p'] tol_p, tol_m = get_net_options(net, 'tol_m', 'tol_p') - newton_raphson(net, solve_hydraulics, 'hydraulics', vars, [tol_m, tol_p], ['branch', 'node'], 'max_iter_hyd') + newton_raphson(net, solve_hydraulics, 'hydraulics', solver_vars, [tol_m, tol_p], + ['branch', 'node'], 'max_iter_hyd') if net.converged: set_user_pf_options(net, hyd_flag=True) @@ -185,9 +197,10 @@ def heat_transfer(net): if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") - vars = ['Tout', 'T'] + solver_vars = ['Tout', 'T'] tol_T = next(get_net_options(net, 'tol_T')) - newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['branch', 'node'], 'max_iter_therm') + newton_raphson(net, solve_temperature, 'heat', solver_vars, [tol_T, tol_T], ['branch', 'node'], + 'max_iter_therm') if not net.converged: raise PipeflowNotConverged("The heat transfer calculation did not converge to a " "solution.") @@ -224,10 +237,12 @@ def solve_hydraulics(net): branch_lookups = get_lookup(net, "branch", "from_to_active_hydraulics") for comp in net['component_list']: - comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, + options) calculate_derivatives_hydraulic(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, + options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) m_init_old = branch_pit[:, MDOTINIT].copy() @@ -295,7 +310,7 @@ def set_damping_factor(net, niter, errors): :type net: pandapipesNet :param niter: :type niter: - :param error: an array containing the current residuals of all field variables solved for + :param errors: an array containing the current residuals of all field variables solved for :return: No Output. EXAMPLE: @@ -312,36 +327,39 @@ def set_damping_factor(net, niter, errors): return error_increased -def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names): +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, + solver_vars, pit_names): # Control of damping factor if nonlinear_method == "automatic": errors_increased = set_damping_factor(net, niter, errors) logger.debug("alpha: %s" % get_net_option(net, "alpha")) - for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): + for error_increased, var, val, pit in zip(errors_increased, solver_vars, vals_old, + pit_names): if error_increased: - # todo: not working in bidirectional mode as bidirectional is not distinguishing between \ - # hydraulics and heat transfer active pit + # todo: not working in bidirectional mode as bidirectional is not distinguishing \ + # between hydraulics and heat transfer active pit net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val if get_net_option(net, "alpha") != 1: net.converged = False return elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") - for error, var, tol in zip(errors.values(), vars, tols): - converged = error[niter] <= tol - if not converged: break + converged = True + for error, var, tol in zip(errors.values(), solver_vars, tols): + converged = converged and error[niter] <= tol logger.debug("error_%s: %s" % (var, error[niter])) net.converged = converged and residual_norm <= tol_res -def log_final_results(net, solver, niter, residual_norm, vars, tols): +def log_final_results(net, solver, niter, residual_norm, solver_vars, tols): logger.debug("--------------------------------------------------------------------------------") if not net.converged: - logger.debug("Maximum number of iterations reached but %s solver did not converge." % solver) + logger.debug( + "Maximum number of iterations reached but %s solver did not converge." % solver) logger.debug("Norm of residual: %s" % residual_norm) else: logger.debug("Calculation completed. Preparing results...") logger.debug("Converged after %d iterations." % niter) logger.debug("Norm of residual: %s" % residual_norm) - for var, tol in zip(vars, tols): + for var, tol in zip(solver_vars, tols): logger.debug("tolerance for %s: %s" % (var, tol)) From cadde9d3d6fca684209fccd990cd7f0a4f206c54 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 13 May 2024 08:40:12 +0200 Subject: [PATCH 160/237] some more pep --- .../heat_consumer_component.py | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 064c63d0c..f7405ac31 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -5,11 +5,13 @@ import numpy as np from numpy import dtype -from pandapipes.component_models import get_fluid, BranchWZeroLengthComponent, get_component_array, \ - standard_branch_wo_internals_result_lookup +from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array, + standard_branch_wo_internals_result_lookup) from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, \ +from pandapipes.idx_branch import ( + D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE +) from pandapipes.idx_node import TINIT from pandapipes.pf.result_extraction import extract_branch_results_without_internals from pandapipes.properties.properties_toolbox import get_branch_cp @@ -61,7 +63,6 @@ def create_pit_branch_entries(cls, net, branch_pit): :type branch_pit: :return: No Output. """ - node_pit = net['_pit']['node'] hc_pit = super().create_pit_branch_entries(net, branch_pit) hc_pit[:, D] = net[cls.table_name()].diameter_m.values hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 @@ -153,7 +154,8 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo node_pit[from_nodes[t_mask], TINIT] += 10 t_in = node_pit[from_nodes, TINIT] df_dm = - cp[mask] * (t_out - t_in) - hc_pit[mask, LOAD_VEC_BRANCHES] = - consumer_array[mask, cls.QEXT] + df_dm * hc_pit[mask, MDOTINIT] + hc_pit[mask, LOAD_VEC_BRANCHES] = (- consumer_array[mask, cls.QEXT] + df_dm + * hc_pit[mask, MDOTINIT]) hc_pit[mask, JAC_DERIV_DM] = df_dm @classmethod @@ -199,9 +201,10 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), - ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), - ("in_service", "bool"), ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), + ("qext_w", "f8"), ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), + ("treturn_k", "f8"), ("diameter_m", "f8"), ("in_service", "bool"), + ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -216,12 +219,14 @@ def get_result_table(cls, net): :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"] + 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"] + 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 @classmethod @@ -241,5 +246,6 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, - cls.table_name(), mode) + extract_branch_results_without_internals( + net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode + ) From 2778bbcc4f485c42301cb47ee03904403962f429 Mon Sep 17 00:00:00 2001 From: hkoertge Date: Wed, 15 May 2024 13:22:50 +0200 Subject: [PATCH 161/237] added docs requirements to docs_check pipeline removed explicit install of pandapower master --- .github/workflows/run_tests_develop.yml | 3 +-- .github/workflows/run_tests_master.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 6a8fc845a..aaeb6c231 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -129,7 +129,6 @@ jobs: pre-build-command: "apt-get update -y && apt-get install -y git; git --version; python -m pip install --upgrade pip; - python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower; - python -m pip install ." + python -m pip install .[docs];" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 0adfcb402..b11dc6639 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -96,7 +96,6 @@ jobs: pre-build-command: "apt-get update -y && apt-get install -y git; git --version; python -m pip install --upgrade pip; - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; - python -m pip install ." + python -m pip install .[docs]" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" From 688db932a9e89700d1ae22508ab3a57eafa89726 Mon Sep 17 00:00:00 2001 From: hkoertge Date: Wed, 15 May 2024 13:35:38 +0200 Subject: [PATCH 162/237] updated docs/requirements.txt --- doc/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 778fafa16..88d2ee075 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,5 @@ sphinx>=5.3.0 sphinx_rtd_theme>=1.1.1 numpydoc>=1.5.0 -sphinxcontrib.bibtex>=2.5.0 \ No newline at end of file +sphinxcontrib.bibtex>=2.5.0 +sphinx-pyproject \ No newline at end of file From a843786c00264b447eb4935260b5944f83e03d69 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 3 Jun 2024 11:15:31 +0200 Subject: [PATCH 163/237] added workflow trigger --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 6a8fc845a..46865432d 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -11,6 +11,7 @@ on: branches-ignore: [ master ] pull_request: branches-ignore: [ master ] + workflow_dispatch: jobs: build: From 780c4e5010dab3e1c69eb8f740ea6e33bbd304ab Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:02:35 +0200 Subject: [PATCH 164/237] setting text of pipes to None and assuming ambient temperature --- src/pandapipes/create.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 641c98007..53fea55c2 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -374,7 +374,7 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, - alpha_w_per_m2k=0., qext_w=0., text_k=None, name=None, index=None, geodata=None, in_service=True, + alpha_w_per_m2k=0., text_k=None, qext_w=0.,name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -399,10 +399,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 - :param qext_w: External heat feed-in to the pipe in [W] - :type qext_w: float, default 0 :param text_k: Ambient temperature of pipe in [K] :type text_k: float, default None, will be set equal to the net ambient temperature + :param qext_w: External heat feed-in to the pipe in [W] + :type qext_w: float, default 0 :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -446,7 +446,7 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + sections=1, alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -471,10 +471,10 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 + :param text_k: Ambient temperature of pipe in [K] + :type text_k: float, default None, will be set equal to the net ambient temperature :param qext_w: external heat feed-in to the pipe in [W] :type qext_w: float, default 0 - :param text_k: Ambient temperature of pipe in [K] - :type text_k: float, default 293 :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -1265,7 +1265,7 @@ def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, ind def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, - alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, + alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ @@ -1295,7 +1295,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] :type alpha_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] - :type text_k: Iterable or float, default 293 + :type text_k: Iterable or float, default None, will be set equal to the net ambient temperature :param qext_w: External heat feed-in to the pipes in [W] :type qext_w: Iterable or float, default 0 :param name: Name tags for these pipes @@ -1344,7 +1344,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + sections=1, alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ @@ -1373,7 +1373,7 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] :type alpha_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] - :type text_k: Iterable or float, default 293 + :type text_k: Iterable or float, default None, will be set equal to the net ambient temperature :param qext_w: External heat feed-in to the pipes in [W] :type qext_w: Iterable or float, default 0 :param name: Name tags for these pipes From 775331a02e53a476da501c99891633f806443007 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:03:00 +0200 Subject: [PATCH 165/237] adapting the heat consumer tests --- .../api/test_components/test_heat_consumer.py | 127 +++++++++--------- 1 file changed, 61 insertions(+), 66 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index ec0342ae4..029a52123 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -3,12 +3,10 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import copy -import pytest - -import pandapipes import numpy as np import pytest +import pandapipes MDOT = [3, 2] QEXT = [150000, 75000] @@ -18,12 +16,10 @@ def simple_heat_net(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") - juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, - system=["flow"] * 3 + ["return"] * 3) - pandapipes.create_pipes_from_parameters( - net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, - system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 - ) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 400, type='pt') return net @@ -33,10 +29,8 @@ def test_heat_consumer_equivalence(simple_heat_net): net2 = copy.deepcopy(simple_heat_net) juncs = net.junction.index - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) - pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, - controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) @@ -52,8 +46,8 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): net2 = copy.deepcopy(simple_heat_net) juncs = net.junction.index - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, qext_w=QEXT) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, + qext_w=QEXT) pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) @@ -63,18 +57,17 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) + def test_heat_consumer_equivalence2(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") - mdot = [3, 3] + mdot = [1, 1] qext = [150000, 75000] - juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, - system=["flow"] * 3 + ["return"] * 3) - pandapipes.create_pipes_from_parameters( - net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, - system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 - ) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') net2 = copy.deepcopy(net) @@ -82,34 +75,26 @@ def test_heat_consumer_equivalence2(): net4 = copy.deepcopy(net) net5 = copy.deepcopy(net) - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - qext_w=qext[1]) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], qext_w=qext[1]) pandapipes.pipeflow(net, mode="bidirectional") - pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, - qext_w=qext[1]) - pandapipes.pipeflow(net2, mode="bidirectional", iter=20, alpha=0.65) + pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k=263.4459264973806, qext_w=qext[1]) + pandapipes.pipeflow(net2, mode="bidirectional", iter=25, alpha=0.5) - pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=5.9673377831196035, - qext_w=qext[1]) + pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=17.82611044059695, qext_w=qext[1]) pandapipes.pipeflow(net3, mode="bidirectional") - pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) + pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net4, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - treturn_k= 285.4461399735642) + treturn_k=263.4459264973806) pandapipes.pipeflow(net4, mode="bidirectional") - pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) + pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net5, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - deltat_k=5.9673377831196035) + deltat_k=17.82611044059695) pandapipes.pipeflow(net5, mode="bidirectional") assert np.allclose(net2.res_junction, net.res_junction) @@ -128,13 +113,12 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): with pytest.raises(AttributeError): # check for less than 2 set parameters - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=None, + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], qext_w=None, treturn_k=None) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, qext_w=[QEXT[0], None]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, + qext_w=[QEXT[0], None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, @@ -145,52 +129,63 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): controlled_mdot_kg_per_s=None) -@pytest.mark.xfail(reason="Can only be tested once models for deltat_k and treturn_k" - " are implemented for heat consumers.") def test_heat_consumer_creation_not_allowed_2(simple_heat_net): net = copy.deepcopy(simple_heat_net) juncs = net.junction.index with pytest.raises(AttributeError): # check for more than 2 set parameters - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0], - treturn_k=390) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], + qext_w=QEXT[0], treturn_k=390) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, deltat_k=20, treturn_k=390) with pytest.raises(AttributeError): # check for more than 2 set parameters - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=[30, 40], treturn_k=[390, 385]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=[30, 40], + treturn_k=[390, 385]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) - with pytest.raises(AttributeError): - # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, deltat_k=[20, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + with pytest.raises(AttributeError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=[390, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in all consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - treturn_k=None, controlled_mdot_kg_per_s=None) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=None, + controlled_mdot_kg_per_s=None) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=[30, 40], treturn_k=[390, 385]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=[30, 40], + treturn_k=[390, 385]) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given as single values - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=30, treturn_k=390) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=30, treturn_k=390) + + +def test_heat_consumer_qext_zero(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, treturn_k=263.4459264973806, qext_w=0) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=1, qext_w=7500) + + pandapipes.pipeflow(net, mode="bidirectional", iter=25, alpha=0.5) + + assert net.res_junction.at[juncs[4], 't_k'] != 263.4459264973806 if __name__ == '__main__': From fa0aa460ccafb5813d84a619b665f75b81afc5ce Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:03:38 +0200 Subject: [PATCH 166/237] from node t and to node t are no fix entries and can be passed from active to general pit --- src/pandapipes/pf/result_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 0dfaa2c7a..6a4b616a0 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -286,7 +286,7 @@ def extract_results_active_pit(net, mode="hydraulics"): result_branch_col = MDOTINIT if mode == "hydraulics" else TOUTINIT not_affected_branch_col = TOUTINIT if mode == "hydraulics" else MDOTINIT copied_branch_cols = np.array([i for i in range(net["_pit"]["branch"].shape[1]) - if i not in [FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, + if i not in [FROM_NODE, TO_NODE, not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] From 86486517d9d651c341e402d2726a21fff27f22ca Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:04:15 +0200 Subject: [PATCH 167/237] further adaption of heat consumer component --- .../heat_consumer_component.py | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index f7405ac31..367caf239 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -8,11 +8,10 @@ from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup) from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import ( - D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, - LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE -) +from pandapipes.idx_branch import (D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, + LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T) from pandapipes.idx_node import TINIT +from pandapipes.pf.pipeflow_setup import get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals from pandapipes.properties.properties_toolbox import get_branch_cp @@ -66,11 +65,12 @@ def create_pit_branch_entries(cls, net, branch_pit): hc_pit = super().create_pit_branch_entries(net, branch_pit) hc_pit[:, D] = net[cls.table_name()].diameter_m.values hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 - hc_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values - hc_pit[:, QEXT] = net[cls.table_name()].qext_w.values - # causes otherwise problems in case of mode Q - hc_pit[np.isnan(hc_pit[:, MDOTINIT]), MDOTINIT] = 0.1 - hc_pit[hc_pit[:, QEXT] == 0, ACTIVE] = False + qext = net[cls.table_name()].qext_w.values + hc_pit[~np.isnan(qext), QEXT] = qext[~np.isnan(qext)] + mdot = net[cls.table_name()].controlled_mdot_kg_per_s.values + hc_pit[~np.isnan(mdot), MDOTINIT] = mdot[~np.isnan(mdot)] + treturn = net[cls.table_name()].treturn_k.values + hc_pit[~np.isnan(treturn), TOUTINIT] = treturn[~np.isnan(treturn)] return hc_pit @classmethod @@ -88,14 +88,15 @@ def create_component_array(cls, net, component_pits): """ tbl = net[cls.table_name()] consumer_array = np.zeros(shape=(len(tbl), cls.internal_cols), dtype=np.float64) - consumer_array[:, cls.MASS] = tbl.controlled_mdot_kg_per_s.values - consumer_array[:, cls.QEXT] = tbl.qext_w.values consumer_array[:, cls.DELTAT] = tbl.deltat_k.values - consumer_array[:, cls.TRETURN] = tbl.treturn_k.values - mf = ~np.isnan(consumer_array[:, cls.MASS]) - qe = ~np.isnan(consumer_array[:, cls.QEXT]) - dt = ~np.isnan(consumer_array[:, cls.DELTAT]) - tr = ~np.isnan(consumer_array[:, cls.TRETURN]) + mf = tbl.controlled_mdot_kg_per_s.values + tr = tbl.treturn_k.values + dt = tbl.deltat_k.values + qe = tbl.qext_w.values + mf = ~np.isnan(mf) + tr = ~np.isnan(tr) + dt = ~np.isnan(dt) + qe = ~np.isnan(qe) consumer_array[mf & dt, cls.MODE] = cls.MF_DT consumer_array[mf & tr, cls.MODE] = cls.MF_TR consumer_array[qe & mf, cls.MODE] = cls.QE_MF @@ -112,8 +113,8 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo mask = consumer_array[:, cls.MODE] == cls.QE_DT if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - deltat = net[cls.table_name()].deltat_k.values - mass = consumer_array[mask, cls.QEXT] / (cp[mask] * (deltat[mask])) + deltat = consumer_array[:, cls.DELTAT] + mass = hc_pit[mask, QEXT] / (cp[mask] * (deltat[mask])) hc_pit[mask, MDOTINIT] = mass @classmethod @@ -148,15 +149,15 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo mask = consumer_array[:, cls.MODE] == cls.QE_TR if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) - t_out = consumer_array[mask, cls.TRETURN] - t_mask = hc_pit[mask, TOUTINIT] == node_pit[from_nodes, TINIT] - node_pit[from_nodes[t_mask], TINIT] += 10 + from_nodes = hc_pit[:, FROM_NODE_T].astype(int) t_in = node_pit[from_nodes, TINIT] - df_dm = - cp[mask] * (t_out - t_in) - hc_pit[mask, LOAD_VEC_BRANCHES] = (- consumer_array[mask, cls.QEXT] + df_dm - * hc_pit[mask, MDOTINIT]) - hc_pit[mask, JAC_DERIV_DM] = df_dm + t_out = hc_pit[:, TOUTINIT] + + df_dm = - cp * (t_out - t_in) + hc_pit[mask, LOAD_VEC_BRANCHES] = - hc_pit[mask, QEXT] + df_dm[mask] * hc_pit[mask, MDOTINIT] + mask_equal = t_out == t_in + hc_pit[mask & mask_equal, MDOTINIT] = 0 + hc_pit[mask & ~mask_equal, JAC_DERIV_DM] = df_dm[mask & ~mask_equal] @classmethod def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): @@ -166,7 +167,7 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look mask = consumer_array[:, cls.MODE] == cls.MF_DT if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - q_ext = cp[mask] * consumer_array[mask, cls.MASS] * consumer_array[mask, cls.DELTAT] + q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * consumer_array[mask, cls.DELTAT] hc_pit[mask, QEXT] = q_ext mask = consumer_array[:, cls.MODE] == cls.MF_TR @@ -175,7 +176,7 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) t_in = node_pit[from_nodes, TINIT] t_out = hc_pit[mask, TOUTINIT] - q_ext = cp[mask] * consumer_array[mask, cls.MASS] * (t_in - t_out) + q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * (t_in - t_out) hc_pit[mask, QEXT] = q_ext @classmethod @@ -188,9 +189,8 @@ def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_looku mask = np.isin(consumer_array[:, cls.MODE], [cls.MF_TR, cls.QE_TR]) if np.any(mask): hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0 - hc_pit[mask, JAC_DERIV_DTOUT] = -1 + hc_pit[mask, JAC_DERIV_DTOUT] = 1 hc_pit[mask, JAC_DERIV_DT] = 0 - hc_pit[mask, TOUTINIT] = consumer_array[mask, cls.TRETURN] @classmethod def get_component_input(cls): @@ -201,10 +201,9 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), - ("qext_w", "f8"), ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), - ("treturn_k", "f8"), ("diameter_m", "f8"), ("in_service", "bool"), - ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), + ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), + ("in_service", "bool"), ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -219,14 +218,13 @@ def get_result_table(cls, net): :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"] + 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"] + 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"] + output += ['deltat_k', 'qext_w'] return output, True @classmethod @@ -246,6 +244,18 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals( - net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode - ) + extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, + cls.table_name(), mode) + + node_pit = net['_pit']['node'] + branch_pit = net['_active_pit']['branch'] + branch_lookups = get_lookup(net, "branch", "from_to_active_heat_transfer") + f, t = branch_lookups[cls.table_name()] + + res_table = net["res_" + cls.table_name()] + + res_table['qext_w'].values[:] = branch_pit[f:t, QEXT] + from_nodes = branch_pit[f:t, FROM_NODE_T].astype(int) + t_from = node_pit[from_nodes, TINIT] + tout = branch_pit[f:t, TOUTINIT] + res_table['deltat_k'].values[:] = t_from - tout From e0480c3df0ce53e6afecdaa7f4a4728e539f9825 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 10 Jun 2024 13:07:37 +0200 Subject: [PATCH 168/237] -added relying and changed build in github test actions --- .github/workflows/run_tests_develop.yml | 39 +++++++++++++++++++++++ .github/workflows/run_tests_master.yml | 41 ++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 6a8fc845a..f8d973224 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -14,6 +14,45 @@ on: jobs: build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest igraph pytest-split + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install pandapower + python -m pip install . + shell: bash + - name: List all installed packages + run: | + python -m pip list + - name: Test with pytest + if: ${{ matrix.python-version != '3.9' }} + run: | + python -m pytest + - name: Test with pytest and Codecov + if: ${{ matrix.python-version == '3.9' }} + run: | + python -m pip install pytest-cov + python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + if: ${{ matrix.python-version == '3.9' }} + uses: codecov/codecov-action@v1 + with: + verbose: true + + relying: runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 0adfcb402..61f81c5c8 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -30,7 +30,7 @@ jobs: python -m pip install pytest igraph pytest-split if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; + python -m pip install pandapower; python -m pip install . shell: bash - name: List all installed packages @@ -51,6 +51,45 @@ jobs: with: verbose: true + relying: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest igraph pytest-split + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; + python -m pip install . + shell: bash + - name: List all installed packages + run: | + python -m pip list + - name: Test with pytest + if: ${{ matrix.python-version != '3.9' }} + run: | + python -m pytest + - name: Test with pytest and Codecov + if: ${{ matrix.python-version == '3.9' }} + run: | + python -m pip install pytest-cov + python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + if: ${{ matrix.python-version == '3.9' }} + uses: codecov/codecov-action@v1 + with: + verbose: true + tutorial_tests: runs-on: ${{ matrix.os }} strategy: From 930c3d445ec545d1bc8514d7c6e465353dae21c8 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 10 Jun 2024 13:13:35 +0200 Subject: [PATCH 169/237] -removed codecov from relying tests --- .github/workflows/run_tests_develop.yml | 10 ---------- .github/workflows/run_tests_master.yml | 12 +----------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index f8d973224..25ffe7aff 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -80,16 +80,6 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest - - name: Test with pytest and Codecov - if: ${{ matrix.python-version == '3.9' }} - run: | - python -m pip install pytest-cov - python -m pytest --cov=./ --cov-report=xml - - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v1 - with: - verbose: true linting: runs-on: ${{ matrix.os }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 61f81c5c8..33c6bca97 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -79,17 +79,7 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest - - name: Test with pytest and Codecov - if: ${{ matrix.python-version == '3.9' }} - run: | - python -m pip install pytest-cov - python -m pytest --cov=./ --cov-report=xml - - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v1 - with: - verbose: true - + tutorial_tests: runs-on: ${{ matrix.os }} strategy: From bf3d4ee511c20b3dc0e0e38394944aeadd7006fb Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 11 Jun 2024 10:09:52 +0200 Subject: [PATCH 170/237] -added src syspath --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 31072d076..1170f4a0c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -17,7 +17,7 @@ sys.path.append(os.path.abspath('../..')) sys.path.append(os.path.abspath('../../..')) sys.path.append(os.path.abspath('../../../pandapower')) - +sys.path.append(os.path.abspath('../../src')) master_doc = 'index' # -- Project information ----------------------------------------------------- From afd9f3e576206e8101e04044831c6632fac846e7 Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 11 Jun 2024 10:16:58 +0200 Subject: [PATCH 171/237] -changed readthedocs yml back --- .readthedocs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.readthedocs.yml b/.readthedocs.yml index b6911a40a..202694c89 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,4 +7,6 @@ build: python: install: + - method: pip + path: . - requirements: doc/requirements.txt \ No newline at end of file From 953b325182e4a1eca2b05f362634fa6d593c0feb Mon Sep 17 00:00:00 2001 From: eprade Date: Fri, 14 Jun 2024 16:47:21 +0200 Subject: [PATCH 172/237] -changed plotting patch of heat consumer --- src/pandapipes/plotting/collections.py | 2 +- src/pandapipes/plotting/patch_makers.py | 77 +++++++++++++++++++------ 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index 7e68b65f2..b05d8babf 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -670,7 +670,7 @@ def create_heat_consumer_collection(net, hec=None, table_name='heat_consumer', s junction_geodata=None, color='k', infofunc=None, picker=False, **kwargs): """ - Creates a matplotlib patch collection of pandapipes compressors. Compressors are + Creates a matplotlib patch collection of pandapipes heat_consumers. Heat consumers are plotted in the center between two junctions. :param net: The pandapipes network diff --git a/src/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py index 0389f630e..6e3cbade1 100644 --- a/src/pandapipes/plotting/patch_makers.py +++ b/src/pandapipes/plotting/patch_makers.py @@ -233,33 +233,74 @@ def heat_consumer_patches(coords, size, **kwargs): m = 3 * size / 4 direc = diff / np.sqrt(diff[0] ** 2 + diff[1] ** 2) normal = np.array([-direc[1], direc[0]]) + circle_center = p1 + diff / 2 + triangle_center = circle_center + direc * size + radius = size + rectangle_size = 5 * size + triangle1, triangle2 = create_triangles(triangle_center + direc * radius, size/1.7, direc, normal, edgecolor) + polys.append(triangle1) + polys.append(triangle2) + path1 = (p1 + diff / 2 + direc * m / 2) + normal * (size * 9 / 8) - path2 = p1 + diff / 2 + direc * m / 2 + path2 = p1 + diff / 2 + direc * m / 2 - normal*size/5 path3 = p1 + diff / 2 + normal * size / 3 - path4 = p1 + diff / 2 - direc * m / 2 + path4 = p1 + diff / 2 - direc * m / 2 - normal*size/5 path5 = (p1 + diff / 2 - direc * m / 2) + normal * (size * 9 / 8) + path = [path1, path2, path3, path4, path5] - radius = size # np.sqrt(diff[0]**2+diff[1]**2)/15 + # np.sqrt(diff[0]**2+diff[1]**2)/15 pa = Path(path) - polys.append(Circle(p1 + diff / 2, radius=radius, edgecolor=edge_col, facecolor=face_col, - lw=lw)) polys.append(PathPatch(pa, fill=False, lw=lw, edgecolor=edge_col)) - # Calculate the endpoints of the line segments passing through the circle - circle_center = p1 + diff / 2 - line1_start = p1 - line1_end = circle_center - direc * radius - line2_start = circle_center + direc * radius - line2_end = p2 + angle = np.arctan2(*diff) + vec_size = _rotate_dim2(np.array([0, size]), angle) + vec_size_or = _rotate_dim2(np.array([0, size * 1.2/2]), angle + np.pi / 2) + pll = p1 + diff / 2 - vec_size + vec_size_or + - # Append the line segments to the list of lines - lines.append([line1_start, line1_end]) - lines.append([line2_start, line2_end]) + polys.append(Rectangle(pll, rectangle_size, rectangle_size/4, angle=np.rad2deg(-angle + np.pi / 2), + edgecolor=edgecolor, facecolor='none', lw=lw)) - # Connect the line passing through the circle with the main line - connect_line_start = line1_end - connect_line_end = line2_start - lines.append([connect_line_start, connect_line_end]) + lines.append([p2, p1]) return lines, polys, {} + + +def create_triangles(center, size, direc, normal, edgecolor): + x, y = center + radius = size + + # Create the first triangle + verts1 = [ + center + direc * radius, # top + center + normal * radius, # bottom left + center - normal * radius, # bottom right + center + direc * radius # back to top + ] + codes1 = [ + Path.MOVETO, + Path.LINETO, + Path.LINETO, + Path.CLOSEPOLY + ] + + # Create the second triangle mirrored at the peak + mirrored_center = center + 2 * direc * radius + verts2 = [ + mirrored_center - direc * radius, # top + mirrored_center + normal * radius, # bottom left + mirrored_center - normal * radius, # bottom right + mirrored_center - direc * radius # back to top + ] + codes2 = [ + Path.MOVETO, + Path.LINETO, + Path.LINETO, + Path.CLOSEPOLY + ] + + path1 = Path(verts1, codes1) + path2 = Path(verts2, codes2) + + return PathPatch(path1, fill=False, lw=2, edgecolor=edgecolor), PathPatch(path2, fill=False, lw=2, edgecolor=edgecolor) \ No newline at end of file From 91fbca0d09ea622a7130661bd7c46ca06c6535a1 Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 17 Jun 2024 08:39:02 +0200 Subject: [PATCH 173/237] -doc --- src/pandapipes/plotting/patch_makers.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py index 6e3cbade1..162a089bc 100644 --- a/src/pandapipes/plotting/patch_makers.py +++ b/src/pandapipes/plotting/patch_makers.py @@ -220,6 +220,17 @@ def pressure_control_patches(coords, size, **kwargs): return lines, polys, {} def heat_consumer_patches(coords, size, **kwargs): + """ + Creates patches for matplotlib plotting of heat consumer component + :param coords: + :type coords: + :param size: + :type size: + :param kwargs: + :type kwargs: + :return: + :rtype: + """ polys, lines = [], [] facecolor = kwargs.get("patch_facecolor", "w") edgecolor = kwargs.get("patch_edgecolor", "k") @@ -268,6 +279,21 @@ def heat_consumer_patches(coords, size, **kwargs): def create_triangles(center, size, direc, normal, edgecolor): + """ + Creates a pathpatch for triangles + :param center: + :type center: + :param size: + :type size: + :param direc: + :type direc: + :param normal: + :type normal: + :param edgecolor: + :type edgecolor: + :return: + :rtype: + """ x, y = center radius = size From ec6f723882b1eff186934ad6d8079259a36c292c Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 17 Jun 2024 14:15:50 +0200 Subject: [PATCH 174/237] -codecav changes --- src/pandapipes/plotting/patch_makers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/plotting/patch_makers.py b/src/pandapipes/plotting/patch_makers.py index 162a089bc..f2d339fa3 100644 --- a/src/pandapipes/plotting/patch_makers.py +++ b/src/pandapipes/plotting/patch_makers.py @@ -3,7 +3,7 @@ # 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 matplotlib.patches import RegularPolygon, Rectangle, Circle, PathPatch, FancyArrow, Polygon +from matplotlib.patches import RegularPolygon, Rectangle, Circle, PathPatch, FancyArrow from matplotlib.path import Path from pandapower.plotting.plotting_toolbox import get_color_list, _rotate_dim2, get_angle_list, \ get_list @@ -294,7 +294,7 @@ def create_triangles(center, size, direc, normal, edgecolor): :return: :rtype: """ - x, y = center + radius = size # Create the first triangle From c524765c75fdad891b9263468fe6c8592b7f6133 Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:22:54 +0200 Subject: [PATCH 175/237] Update CHANGELOG.rst --- CHANGELOG.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d06784208..e4aa6f00d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,10 +3,7 @@ Change Log -[ADDED] heat_consumer plotting - -[latest] - RELEASEDATE - -- [CHANGED] switched from setup.py to pyproject.toml +-[CHANGED] switched from setup.py to pyproject.toml From e6da5e54cdf83ef4b2a35780cd850fcfb57303a4 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 18 Jun 2024 07:31:00 +0200 Subject: [PATCH 176/237] numpy 2.0 migration --- .../component_models/component_toolbox.py | 2 +- .../converter/stanet/data_cleaning.py | 2 +- .../converter/stanet/preparing_steps.py | 8 +++--- .../converter/stanet/table_creation.py | 28 +++++++++---------- src/pandapipes/pf/internals_toolbox.py | 2 +- src/pandapipes/pf/result_extraction.py | 4 +-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 840929bc4..35fa2ac33 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -88,7 +88,7 @@ def init_results_element(net, element, output, all_float): dtype=np.float64) else: net[res_element] = pd.DataFrame(np.zeros(0, dtype=output), index=[]) - net[res_element] = pd.DataFrame(np.NaN, index=net[element].index, + net[res_element] = pd.DataFrame(np.nan, index=net[element].index, columns=net[res_element].columns) diff --git a/src/pandapipes/converter/stanet/data_cleaning.py b/src/pandapipes/converter/stanet/data_cleaning.py index aa7389530..2aa6db04a 100644 --- a/src/pandapipes/converter/stanet/data_cleaning.py +++ b/src/pandapipes/converter/stanet/data_cleaning.py @@ -20,7 +20,7 @@ def sort_by_pos(group): def sort_by_flow(group): group["follower"] = group.FLUSSB.apply(lambda b: group.index[group.FLUSSA == b][0] - if b in group.FLUSSA.values else np.NaN) + if b in group.FLUSSA.values else np.nan) ls = list(group.loc[~group.FLUSSA.isin(group.FLUSSB)].index) assert len(ls) == 1 while len(ls) < len(group): diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index f3edbcb94..61fa06f7d 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -241,7 +241,7 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe node_val = node_geo.loc[pipe_data.loc[pipes_to_check, node_nr].values, node_name].values if pipe_name not in pipe_data.columns: - pipe_data[pipe_name] = np.NaN + pipe_data[pipe_name] = np.nan pipe_data.loc[pipes_to_check, pipe_name] = node_val current_pipe_data = pipe_data.loc[pipes_to_check] if not np.allclose(node_val, current_pipe_data[pipe_name].values): @@ -401,9 +401,9 @@ def connection_pipe_section_table(stored_data, pipe_geodata, house_pipe_geodata, # but requires checks (e.g. positioning on pipe, max. 2 valves per pipe) c2 = stored_data["slider_valves"].loc[:, [c for c in required_columns if c not in ["PRECH", "VMA", "VMB"]]] - c2["PRECH"] = np.NaN - c2["VMA"] = np.NaN - c2["VMB"] = np.NaN + c2["PRECH"] = np.nan + c2["VMA"] = np.nan + c2["VMB"] = np.nan c2["type"] = "slider_valves" connections = pd.concat([connections, c2], ignore_index=True) diff --git a/src/pandapipes/converter/stanet/table_creation.py b/src/pandapipes/converter/stanet/table_creation.py index 280d3a64a..83d6aeb74 100644 --- a/src/pandapipes/converter/stanet/table_creation.py +++ b/src/pandapipes/converter/stanet/table_creation.py @@ -149,9 +149,9 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li j_ref = net.junction.loc[node_mapping[from_stanet_nr], :] j_ref_geodata = net.junction_geodata.loc[node_mapping[from_stanet_nr], :] j_aux = pandapipes.create_junction( - net, np.NaN, tfluid_k=net_params["medium_temp_K"], height_m=j_ref['height_m'], + net, np.nan, tfluid_k=net_params["medium_temp_K"], height_m=j_ref['height_m'], name='aux_' + j_ref['stanet_id'], geodata=(j_ref_geodata.x, j_ref_geodata.y), - stanet_nr=-999, stanet_id='aux_' + j_ref['stanet_id'], p_stanet=np.NaN, + stanet_nr=-999, stanet_id='aux_' + j_ref['stanet_id'], p_stanet=np.nan, stanet_active=bool(row.ISACTIVE), **add_info ) text_k = 293 @@ -169,7 +169,7 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li net, j_aux, node_mapping[to_stanet_nr], diameter_m=float(row.DM / 1000), opened=row.AUF == 'J', loss_coefficient=0, name="valve_%s_%s" % ('aux_' + str(row.ENDNAM), str(row.ENDNAM)), - stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=np.NaN, + stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=np.nan, stanet_active=bool(row.ISACTIVE), **add_info ) @@ -382,7 +382,7 @@ def create_control_components(net, stored_data, index_mapping, net_params, add_l drop_eg = net.ext_grid.loc[net.ext_grid.junction.isin(to_junctions[is_pc])].index net.ext_grid.drop(drop_eg, inplace=True) - net.junction.loc[to_junctions[is_pc], "pn_bar"] = np.NaN + net.junction.loc[to_junctions[is_pc], "pn_bar"] = np.nan pandapipes.reindex_elements(net, "ext_grid", np.arange(len(net.ext_grid))) if np.any(is_fc): @@ -463,7 +463,7 @@ def create_junctions_from_connections(net, connection_table, net_params, index_m continue stanet_ids = cons.STANETID.astype(str).values stanet_nrs = cons.RECNO.astype(np.int32).values - p_stanet = cons.PRECH.astype(np.float64).values if houses_in_calculation else np.NaN + p_stanet = cons.PRECH.astype(np.float64).values if houses_in_calculation else np.nan names = stanet_ids if con_type not in extend_from_to else \ stanet_ids + node_type.replace(con_type, "") geo = np.array([cons.geo.apply(lambda g: g[0]), cons.geo.apply(lambda g: g[1])]).transpose() @@ -475,7 +475,7 @@ def create_junctions_from_connections(net, connection_table, net_params, index_m if add_layers: add_info["stanet_layer"] = cons.LAYER.values.astype(str) pp_indices = pandapipes.create_junctions( - net, len(cons), np.NaN, net_params["medium_temp_K"], name=names, + net, len(cons), np.nan, net_params["medium_temp_K"], name=names, height_m=cons.GEOH.astype(np.float64).values, geodata=geo, type=cons.type.values, in_service=in_service, stanet_nr=stanet_nrs, stanet_id=stanet_ids, p_stanet=p_stanet, stanet_system=cons.CLIENTTYP.replace(CLIENT_TYPES_OF_PIPES).values, @@ -798,13 +798,13 @@ def build_house_junctions(net, index_mapping, hh_types, hh_recno, house_table, m add_info["stanet_layer"] = connected_houses.LAYER.values.astype(str) # create junctions for houses that are directly connected via house pipes pp_ind = pandapipes.create_junctions( - net, len(connected_houses), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(connected_houses), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=heights_houses.astype(np.float64), geodata=geodata, in_service=houses_in_calculation, name=["house_%s" % hn for hn in connected_houses.RECNO.values], type="house", stanet_nr=connected_houses.RECNO.values, stanet_id=connected_houses.STANETID.values.astype(str), - p_stanet=connected_houses.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=connected_houses.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=connected_houses.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -827,13 +827,13 @@ def build_meter_junctions(net, index_mapping, hh_types, hh_recno, meter_table, n add_info["stanet_layer"] = connected_meters.LAYER.values.astype(str) # create junctions for meters that are directly connected via house pipes pp_ind = pandapipes.create_junctions( - net, len(connected_meters), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(connected_meters), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=connected_meters.GEOH.values.astype(np.float64), name=connected_meters.STANETID.values.astype(str), geodata=geodata, type="meter", stanet_nr=connected_meters.RECNO.values, stanet_id=connected_meters.STANETID.astype(str), in_service=houses_in_calculation, - p_stanet=connected_meters.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=connected_meters.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=connected_meters.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -853,12 +853,12 @@ def build_house_node_junctions(net, index_mapping, stored_data, net_params, hous if add_layers: add_info["stanet_layer"] = house_nodes.LAYER.values.astype(str) pp_ind = pandapipes.create_junctions( - net, len(house_node_nrs), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(house_node_nrs), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=house_nodes.GEOH.values.astype(np.float64), name=house_nodes.STANETID.values.astype(str), geodata=geodata, type="house_node", stanet_nr=house_node_nrs, stanet_id=house_nodes.STANETID.astype(str), in_service=houses_in_calculation, - p_stanet=house_nodes.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=house_nodes.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=house_nodes.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -1091,7 +1091,7 @@ def create_sinks_meters(net, meter_table, index_mapping, net_params, add_layers) assigned_node_nums = meter_table.KNONUM.astype(np.int32) meter_nrs = meter_table.RECNO.astype(np.int32) - junctions_assigned = pd.Series([node_mapping.get(nn, np.NaN) for nn in assigned_node_nums], + junctions_assigned = pd.Series([node_mapping.get(nn, np.nan) for nn in assigned_node_nums], index=meter_table.index, dtype=float) junctions_connected = pd.Series(index=meter_table.index, dtype=float) @@ -1110,7 +1110,7 @@ def create_sinks_meters(net, meter_table, index_mapping, net_params, add_layers) if np.any(junctions_connected.isnull()): junctions_connected.loc[junctions_connected.isnull()] = \ - [node_mapping.get(n, np.NaN) if not np.isnan(n) else np.NaN for n in + [node_mapping.get(n, np.nan) if not np.isnan(n) else np.nan for n in meter_table.KNONUM.loc[junctions_connected.isnull()].values] logger.warning("The meters %s cannot be mapped to a house connection node and will be " "assigned to nodes %s" diff --git a/src/pandapipes/pf/internals_toolbox.py b/src/pandapipes/pf/internals_toolbox.py index 8e094476f..a1e0db5f7 100644 --- a/src/pandapipes/pf/internals_toolbox.py +++ b/src/pandapipes/pf/internals_toolbox.py @@ -44,7 +44,7 @@ def _sum_by_group_sorted(indices, *values): val[i] = val[i][index] still_na = nans[index] val[i][1:] = val[i][1:] - val[i][:-1] - val[i][still_na] = np.NaN + val[i][still_na] = np.nan else: np.cumsum(val[i], out=val[i]) val[i] = val[i][index] diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 5e277608f..bc87b1734 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -290,10 +290,10 @@ def extract_results_active_pit(net, mode="hydraulics"): not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] - net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN + net["_pit"]["node"][~nodes_connected, result_node_col] = np.nan net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.nan net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols] From a9ea1c5640d49095aff4e8d8da391888a0d6a406 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 18 Jun 2024 07:38:49 +0200 Subject: [PATCH 177/237] remove workflow_dispatch --- .github/workflows/run_tests_develop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 2997e581e..c3f5e1070 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -11,7 +11,6 @@ on: branches-ignore: [ master ] pull_request: branches-ignore: [ master ] - workflow_dispatch: jobs: build: From b30161278c4e4a658d11e40ac311da8782cab5c2 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 09:17:23 +0200 Subject: [PATCH 178/237] added a codacy project token, to upload coverage reports. --- .github/workflows/release.yml | 3 +++ .github/workflows/run_tests_develop.yml | 5 ++++- .github/workflows/run_tests_master.yml | 17 ++++++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71bafbf41..1778e9d95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,9 @@ on: - 'testpypi' - 'pypi' +env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: upload: diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 6a8fc845a..4732fb167 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -12,6 +12,9 @@ on: pull_request: branches-ignore: [ master ] +env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + jobs: build: runs-on: ${{ matrix.os }} @@ -48,7 +51,7 @@ jobs: python -m pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: verbose: true diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 0adfcb402..99d064407 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -11,6 +11,9 @@ on: pull_request: branches: [ master ] +env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + jobs: build: runs-on: ${{ matrix.os }} @@ -19,9 +22,9 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -47,7 +50,7 @@ jobs: python -m pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: verbose: true @@ -58,9 +61,9 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -85,9 +88,9 @@ jobs: matrix: python-version: [ '3.10' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Check docs for Python ${{ matrix.python-version }} From 47dc54aafe55bd761d663c28467b48939a21da58 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 09:36:43 +0200 Subject: [PATCH 179/237] updated versions and added upload feature to codacy, added explicit numba test. --- .github/workflows/release.yml | 3 -- .github/workflows/run_tests_develop.yml | 41 ++++++++++++++----------- .github/workflows/run_tests_master.yml | 34 ++++++++++++-------- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1778e9d95..71bafbf41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,6 @@ on: - 'testpypi' - 'pypi' -env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: upload: diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 4732fb167..5e64bb3b2 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -12,9 +12,6 @@ on: pull_request: branches-ignore: [ master ] -env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: runs-on: ${{ matrix.os }} @@ -23,19 +20,18 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest igraph pytest-split - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - python -m pip install . + python -m pip install .["all"] shell: bash - name: List all installed packages run: | @@ -44,6 +40,11 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest + - name: Test with numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip install numba + python -m pytest - name: Test with pytest and Codecov if: ${{ matrix.python-version == '3.9' }} run: | @@ -62,9 +63,9 @@ jobs: python-version: ['3.10'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -73,7 +74,7 @@ jobs: python -m pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - python -m pip install . + python -m pip install .["all"] shell: bash - name: List all installed packages run: | @@ -94,16 +95,15 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split igraph - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install . @@ -114,6 +114,11 @@ jobs: - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" + - name: Test with numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip install numba + python -m pytest -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest @@ -121,9 +126,9 @@ jobs: matrix: python-version: [ '3.10' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Check docs for Python ${{ matrix.python-version }} @@ -133,6 +138,6 @@ jobs: git --version; python -m pip install --upgrade pip; python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower; - python -m pip install ." + python -m pip install .['all']" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 99d064407..249e0c0ab 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -11,9 +11,6 @@ on: pull_request: branches: [ master ] -env: - CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - jobs: build: runs-on: ${{ matrix.os }} @@ -30,11 +27,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest igraph pytest-split - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; - python -m pip install . + python -m pip install pandapower; + python -m pip install .["all"] shell: bash - name: List all installed packages run: | @@ -43,6 +39,11 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest + - name: Test with numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip install numba + python -m pytest - name: Test with pytest and Codecov if: ${{ matrix.python-version == '3.9' }} run: | @@ -52,7 +53,9 @@ jobs: if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} verbose: true + upload: true tutorial_tests: runs-on: ${{ matrix.os }} @@ -69,11 +72,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split igraph - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower - python -m pip install . + python -m pip install pandapower + python -m pip install .["all"] shell: bash - name: List all installed packages run: | @@ -81,6 +83,12 @@ jobs: - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" + - name: Test with numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip install numba + python -m pytest -n=auto "./tutorials" + docs_check: runs-on: ubuntu-latest @@ -99,7 +107,7 @@ jobs: pre-build-command: "apt-get update -y && apt-get install -y git; git --version; python -m pip install --upgrade pip; - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; - python -m pip install ." + python -m pip install pandapower; + python -m pip install .['all']" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" From 0a29ecafdaa8866e79e1e4e88aabe12d38d02fff Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 09:48:38 +0200 Subject: [PATCH 180/237] added upload to codacy and limited that to run only on master, and ubuntu-latest. --- .github/workflows/run_tests_develop.yml | 2 +- .github/workflows/run_tests_master.yml | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 5e64bb3b2..2ee58f01f 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -118,7 +118,7 @@ jobs: if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install numba - python -m pytest -n=auto "./tutorials" + python -m pytest --nbmake -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 249e0c0ab..d657c4cef 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -53,8 +53,12 @@ jobs: if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} verbose: true + - name: Upload coverage to Codacy + if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} + uses: codacy/codacy-analysis-cli-action@master + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} upload: true tutorial_tests: @@ -87,7 +91,7 @@ jobs: if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install numba - python -m pytest -n=auto "./tutorials" + python -m pytest --nbmake -n=auto "./tutorials" docs_check: From 94c9eb071961d7ccb305696d956ecae0cecf11ae Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:08:29 +0200 Subject: [PATCH 181/237] codacy and codecov running order changed and added ignore for ueless paths. Also we added a check to not upload to codecov everything done on any branch... --- .github/workflows/run_tests_develop.yml | 9 +++++++++ .github/workflows/run_tests_master.yml | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 2ee58f01f..8c129a3f1 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -55,6 +55,15 @@ jobs: uses: codecov/codecov-action@v4 with: verbose: true + dry_run: ${{ github.ref == 'refs/heads/develop' && 'false' || 'true' }} + exclude: | + '**/test/**' + '**/__init__.py' + 'doc/**' + 'tutorials/**' + 'pandapipes/networks/network_files/**' + '**.yml' + '**.rst' linting: runs-on: ${{ matrix.os }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index d657c4cef..b98803817 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -49,17 +49,26 @@ jobs: run: | python -m pip install pytest-cov python -m pytest --cov=./ --cov-report=xml - - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v4 - with: - verbose: true - name: Upload coverage to Codacy if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} uses: codacy/codacy-analysis-cli-action@master with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} upload: true + - name: Upload coverage to Codecov + if: ${{ matrix.python-version == '3.9' }} + uses: codecov/codecov-action@v4 + with: + verbose: true + exclude: | + '**/test/**' + '**/__init__.py' + 'doc/**' + 'tutorials/**' + 'pandapipes/networks/network_files/**' + '**.yml' + '**.rst' + tutorial_tests: runs-on: ${{ matrix.os }} From 2ecc87e927a8c3655f8b1ce7d8baa481a9ef5b16 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:13:39 +0200 Subject: [PATCH 182/237] codacy complains about coverages files so we just ignore them. --- .codacy.yml | 2 ++ .github/workflows/run_tests_master.yml | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.codacy.yml b/.codacy.yml index cad15b592..9823f0c7c 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -7,3 +7,5 @@ exclude_paths: - 'pandapipes/networks/network_files/**' - '**.yml' - '**.rst' + - 'coverage.xml' + - '.coverage' \ No newline at end of file diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index b98803817..52430e676 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -39,6 +39,12 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest + - name: Upload coverage to Codacy + if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} + uses: codacy/codacy-analysis-cli-action@master + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + upload: true - name: Test with numba if: ${{ matrix.python-version == '3.11' }} run: | @@ -49,12 +55,6 @@ jobs: run: | python -m pip install pytest-cov python -m pytest --cov=./ --cov-report=xml - - name: Upload coverage to Codacy - if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} - uses: codacy/codacy-analysis-cli-action@master - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - upload: true - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 From 19b9e71e4af803c6494321c3f0aa624a950f2bdb Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:23:56 +0200 Subject: [PATCH 183/237] removed a logic error from develop and removed a seperate run of codacy for master, since uploading the reports is enough. --- .codacy.yml | 4 +--- .github/workflows/run_tests_develop.yml | 2 +- .github/workflows/run_tests_master.yml | 11 +++++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.codacy.yml b/.codacy.yml index 9823f0c7c..b999552ec 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -6,6 +6,4 @@ exclude_paths: - 'tutorials/**' - 'pandapipes/networks/network_files/**' - '**.yml' - - '**.rst' - - 'coverage.xml' - - '.coverage' \ No newline at end of file + - '**.rst' \ No newline at end of file diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 8c129a3f1..e7ebdd085 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -55,7 +55,7 @@ jobs: uses: codecov/codecov-action@v4 with: verbose: true - dry_run: ${{ github.ref == 'refs/heads/develop' && 'false' || 'true' }} + dry_run: ${{ github.ref != 'refs/heads/develop' }} exclude: | '**/test/**' '**/__init__.py' diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 52430e676..08ed959f0 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -39,12 +39,6 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest - - name: Upload coverage to Codacy - if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} - uses: codacy/codacy-analysis-cli-action@master - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - upload: true - name: Test with numba if: ${{ matrix.python-version == '3.11' }} run: | @@ -55,6 +49,11 @@ jobs: run: | python -m pip install pytest-cov python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage to Codacy + if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} + env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} + run: bash <(curl -Ls https://coverage.codacy.com/get.sh) - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 From 85422d8a066e305a96636cf5bf7f1bfdaea37abf Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:30:25 +0200 Subject: [PATCH 184/237] added coverage for generating more reports. --- .github/workflows/run_tests_master.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 08ed959f0..277af1861 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -43,17 +43,18 @@ jobs: if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install numba - python -m pytest - - name: Test with pytest and Codecov + python -m pytest -n=auto + - name: Test with pytest, Codecov and Coverage if: ${{ matrix.python-version == '3.9' }} run: | - python -m pip install pytest-cov - python -m pytest --cov=./ --cov-report=xml + python -m pip install pytest-cov coverage + coverage run -m pytest --nbmake -n=auto --cov=./ --cov-report=xml - name: Upload coverage to Codacy if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - run: bash <(curl -Ls https://coverage.codacy.com/get.sh) + run: | + bash <(curl -Ls https://coverage.codacy.com/get.sh) - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 From 4021e228545605b418d4a9d10a46ca259a1ae6d8 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:37:00 +0200 Subject: [PATCH 185/237] added recommended parameter. --- .github/workflows/run_tests_master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 277af1861..40a8470bc 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -54,7 +54,7 @@ jobs: env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} run: | - bash <(curl -Ls https://coverage.codacy.com/get.sh) + bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 From f858a43094c54c18348401be131e65982c03cc56 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 10:56:34 +0200 Subject: [PATCH 186/237] added token since v4 of the codecov action script no token isn't supported anymore... --- .github/workflows/run_tests_develop.yml | 1 + .github/workflows/run_tests_master.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index e7ebdd085..5706539d4 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -55,6 +55,7 @@ jobs: uses: codecov/codecov-action@v4 with: verbose: true + token: ${{ secrets.CODECOV_TOKEN }} dry_run: ${{ github.ref != 'refs/heads/develop' }} exclude: | '**/test/**' diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 40a8470bc..2651fdba7 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -59,6 +59,7 @@ jobs: if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 with: + token: ${{ secrets.CODECOV_TOKEN }} verbose: true exclude: | '**/test/**' From 835ebd741b7a6c49d180dcb951c1cb1f2c8ff6f5 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 11:25:41 +0200 Subject: [PATCH 187/237] adapted to copy coverage file and to use pytest-cov since it provides some additional features. --- .github/workflows/run_tests_develop.yml | 2 +- .github/workflows/run_tests_master.yml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 5706539d4..ac4f46a1a 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -49,7 +49,7 @@ jobs: if: ${{ matrix.python-version == '3.9' }} run: | python -m pip install pytest-cov - python -m pytest --cov=./ --cov-report=xml + python -m pytest -n=auto --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: ${{ matrix.python-version == '3.9' }} uses: codecov/codecov-action@v4 diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 2651fdba7..4dd3c27e6 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -47,8 +47,9 @@ jobs: - name: Test with pytest, Codecov and Coverage if: ${{ matrix.python-version == '3.9' }} run: | - python -m pip install pytest-cov coverage - coverage run -m pytest --nbmake -n=auto --cov=./ --cov-report=xml + python -m pip install pytest-cov + python -m pytest --nbmake -n=auto --cov=./ --cov-report=xml + cp ./coverage.xml ./codecov_coverage.xml - name: Upload coverage to Codacy if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} env: @@ -60,6 +61,7 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + file: ./codecov_coverage.xml verbose: true exclude: | '**/test/**' From 02a01d9c720dd29b871201fdbe62413233d72fd4 Mon Sep 17 00:00:00 2001 From: SRDM Date: Thu, 18 Apr 2024 10:35:56 +0200 Subject: [PATCH 188/237] introducing bidirectional calculation --- doc/source/pipeflow/calculation_modes.rst | 6 +- .../abstract_models/branch_models.py | 5 +- .../component_models/component_toolbox.py | 8 +- .../heat_consumer_component.py | 185 ++++----- .../component_models/junction_component.py | 4 +- .../component_models/pipe_component.py | 4 +- .../converter/stanet/preparing_steps.py | 2 +- src/pandapipes/create.py | 353 ++++++++---------- src/pandapipes/pf/derivative_toolbox_numba.py | 5 +- src/pandapipes/pf/pipeflow_setup.py | 43 ++- src/pandapipes/pf/result_extraction.py | 21 +- src/pandapipes/pipeflow.py | 297 +++++++-------- .../test_components/test_circ_pump_mass.py | 2 +- .../test_circ_pump_pressure.py | 2 +- .../test/api/test_components/test_ext_grid.py | 20 +- .../api/test_components/test_flow_control.py | 4 +- .../api/test_components/test_heat_consumer.py | 94 +++-- .../test_components/test_heat_exchanger.py | 2 +- src/pandapipes/test/api/test_time_series.py | 4 +- .../test_heat_transfer_openmodelica.py | 16 +- .../test/pipeflow_internals/test_inservice.py | 16 +- .../test/pipeflow_internals/test_options.py | 12 +- .../test_pipeflow_analytic_comparison.py | 14 +- .../pipeflow_internals/test_pipeflow_modes.py | 2 +- src/pandapipes/test/test_toolbox.py | 1 - ...ular_flow_in_a_district_heating_grid.ipynb | 2 +- 26 files changed, 569 insertions(+), 555 deletions(-) diff --git a/doc/source/pipeflow/calculation_modes.rst b/doc/source/pipeflow/calculation_modes.rst index 6a8b38bbe..b94dc4a81 100644 --- a/doc/source/pipeflow/calculation_modes.rst +++ b/doc/source/pipeflow/calculation_modes.rst @@ -34,7 +34,7 @@ variations are very small. The user has to decide if these assumptions are suitable for his purposes. In future, pandapipes will be extended in order to make sure that calculated temperatures also effect hydraulic fluid properties. To activate temperature calculation, the pipe flow option "mode" has to be set -to "all" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually. +to "sequential", "bidirectional" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually. Hydraulic calculations for incompressible media @@ -92,8 +92,8 @@ In gas flows, the velocity is typically not constant along a pipeline. For this tables for pipes show more entries in comparison with the result tables for incompressible media. -Temperature calculations (pipeflow option: mode = "all" or mode = "heat") -========================================================================= +Temperature calculations (pipeflow option: mode = "sequential", mode = "bidrectional" or mode = "heat") +======================================================================================================= Important parameters of the network main components (junctions and pipes) needed for the calculation are listed in the following table. The :ref:`component section ` of this manual contains diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index 8ebf80323..a486fabaa 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -5,8 +5,8 @@ import numpy as np from pandapipes.component_models.abstract_models.base_component import Component -from pandapipes.idx_branch import MDOTINIT, branch_cols -from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup +from pandapipes.idx_branch import MDOTINIT, branch_cols, TEXT +from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option try: import pandaplan.core.pplog as logging @@ -89,6 +89,7 @@ def create_pit_branch_entries(cls, net, branch_pit): to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) branch_component_pit[:, MDOTINIT] = 0.1 + branch_component_pit[:, TEXT] = get_net_option(net, 'ambient_temperature') return branch_component_pit, node_pit, from_nodes, to_nodes @classmethod diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 840929bc4..67813dcb9 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -137,10 +137,10 @@ def set_entry_check_repeat(pit, column, entry, repeat_number, repeated=True): def set_fixed_node_entries(net, node_pit, junctions, eg_types, p_values, t_values, node_comp, - mode="all"): + mode="sequential"): junction_idx_lookups = get_lookup(net, "node", "index")[node_comp.table_name()] for eg_type in ("p", "t"): - if eg_type not in mode and mode != "all": + if eg_type not in mode and mode != "sequential" and mode!= "bidrectional": continue if eg_type == "p": val_col, type_col, eg_count_col, typ, valid_types, values = \ @@ -200,7 +200,7 @@ def standard_branch_wo_internals_result_lookup(net): return required_results_hyd, required_results_ht -def get_component_array(net, component_name, component_type="branch", only_active=True): +def get_component_array(net, component_name, component_type="branch", mode='hydraulics', only_active=True): """ Returns the internal array of a component. @@ -218,5 +218,5 @@ def get_component_array(net, component_name, component_type="branch", only_activ f_all, t_all = get_lookup(net, component_type, "from_to")[component_name] if not only_active: return net["_pit"]["components"][component_name] - in_service_elm = get_lookup(net, component_type, "active_hydraulics")[f_all:t_all] + in_service_elm = get_lookup(net, component_type, "active_%s"%mode)[f_all:t_all] return net["_pit"]["components"][component_name][in_service_elm] diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index f2f4aaf71..064c63d0c 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -5,12 +5,14 @@ import numpy as np from numpy import dtype -from pandapipes.component_models import get_fluid, \ - BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup +from pandapipes.component_models import get_fluid, BranchWZeroLengthComponent, get_component_array, \ + standard_branch_wo_internals_result_lookup from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, \ - JAC_DERIV_DM, JAC_DERIV_DP, LOAD_VEC_BRANCHES +from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, \ + LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE +from pandapipes.idx_node import TINIT from pandapipes.pf.result_extraction import extract_branch_results_without_internals +from pandapipes.properties.properties_toolbox import get_branch_cp class HeatConsumer(BranchWZeroLengthComponent): @@ -26,17 +28,11 @@ class HeatConsumer(BranchWZeroLengthComponent): internal_cols = 5 - # numbering of given parameters (for mdot, qext, deltat, treturn) - MF = 0 - QE = 1 - DT = 2 - TR = 3 - # heat consumer modes (sum of combinations of given parameters) - MF_QE = 1 - MF_DT = 2 - MF_TR = 4 - QE_DT = 3 + MF_DT = 1 + MF_TR = 2 + QE_MF = 3 + QE_DT = 4 QE_TR = 5 @classmethod @@ -65,12 +61,16 @@ def create_pit_branch_entries(cls, net, branch_pit): :type branch_pit: :return: No Output. """ - hs_pit = super().create_pit_branch_entries(net, branch_pit) - hs_pit[:, D] = net[cls.table_name()].diameter_m.values - hs_pit[:, AREA] = hs_pit[:, D] ** 2 * np.pi / 4 - hs_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values - hs_pit[:, QEXT] = net[cls.table_name()].qext_w.values - return hs_pit + node_pit = net['_pit']['node'] + hc_pit = super().create_pit_branch_entries(net, branch_pit) + hc_pit[:, D] = net[cls.table_name()].diameter_m.values + hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 + hc_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values + hc_pit[:, QEXT] = net[cls.table_name()].qext_w.values + # causes otherwise problems in case of mode Q + hc_pit[np.isnan(hc_pit[:, MDOTINIT]), MDOTINIT] = 0.1 + hc_pit[hc_pit[:, QEXT] == 0, ACTIVE] = False + return hc_pit @classmethod def create_component_array(cls, net, component_pits): @@ -95,9 +95,26 @@ def create_component_array(cls, net, component_pits): qe = ~np.isnan(consumer_array[:, cls.QEXT]) dt = ~np.isnan(consumer_array[:, cls.DELTAT]) tr = ~np.isnan(consumer_array[:, cls.TRETURN]) - consumer_array[:, cls.MODE] = np.sum([mf, qe, dt, tr], axis=0) + consumer_array[mf & dt, cls.MODE] = cls.MF_DT + consumer_array[mf & tr, cls.MODE] = cls.MF_TR + consumer_array[qe & mf, cls.MODE] = cls.QE_MF + consumer_array[qe & dt, cls.MODE] = cls.QE_DT + consumer_array[qe & tr, cls.MODE] = cls.QE_TR component_pits[cls.table_name()] = consumer_array + @classmethod + def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name()) + + mask = consumer_array[:, cls.MODE] == cls.QE_DT + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + deltat = net[cls.table_name()].deltat_k.values + mass = consumer_array[mask, cls.QEXT] / (cp[mask] * (deltat[mask])) + hc_pit[mask, MDOTINIT] = mass + @classmethod def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options): """ @@ -119,50 +136,59 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo # set all pressure derivatives to 0 and velocity to 1; load vector must be 0, as no change # of velocity is allowed during the pipeflow iteration f, t = idx_lookups[cls.table_name()] - fc_branch_pit = branch_pit[f:t, :] - fc_array = get_component_array(net, cls.table_name()) - # TODO: this is more precise, but slower: - # np.isin(fc_array[:, cls.MODE], [cls.MF_QE, cls.MF_DT, cls.MF_TR]) - mdot_controlled = ~np.isnan(fc_array[:, cls.MASS]) - fc_branch_pit[mdot_controlled, JAC_DERIV_DP] = 0 - fc_branch_pit[mdot_controlled, JAC_DERIV_DP1] = 0 - fc_branch_pit[mdot_controlled, JAC_DERIV_DM] = 1 - fc_branch_pit[mdot_controlled, LOAD_VEC_BRANCHES] = 0 - - # @classmethod - # def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): - # f, t = idx_lookups[cls.table_name()] - # hs_pit = branch_pit[f:t, :] - # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) - # hs_pit[mask_t_return, TINIT_OUT] = (hs_pit[mask_t_return, TINIT_OUT] - # - hs_pit[mask_t_return, DELTAT]) - # - # - # @classmethod - # def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): - # """ - # - # :param net: - # :type net: - # :param branch_component_pit: - # :type branch_component_pit: - # :param node_pit: - # :type node_pit: - # :return: - # :rtype: - # """ - # # -(rho * area * cp * v_init * (-t_init_i + t_init_i1 - tl) - # # - alpha * (t_amb - t_m) * length + qext) - # - # f, t = idx_lookups[cls.table_name()] - # hs_pit = branch_pit[f:t, :] - # from_nodes = hs_pit[:, FROM_NODE_T].astype(np.int32) - # - # mask_qext = ~np.isnan(hs_pit[:, QEXT]) - # mask_deltat = ~np.isnan(hs_pit[:, DELTAT]) - # mask_t_return = ~np.isnan(hs_pit[:, TRETURN]) - # mask_mass = ~np.isnan(hs_pit[:, MASS]) - # hs_pit[mask_t_return | mask_deltat, JAC_DERIV_DT1] = 0 + consumer_array = get_component_array(net, cls.table_name()) + + hc_pit = branch_pit[f:t, :] + hc_pit[:, JAC_DERIV_DP] = 0 + hc_pit[:, JAC_DERIV_DP1] = 0 + hc_pit[:, JAC_DERIV_DM] = 1 + hc_pit[:, LOAD_VEC_BRANCHES] = 0 + + mask = consumer_array[:, cls.MODE] == cls.QE_TR + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) + t_out = consumer_array[mask, cls.TRETURN] + t_mask = hc_pit[mask, TOUTINIT] == node_pit[from_nodes, TINIT] + node_pit[from_nodes[t_mask], TINIT] += 10 + t_in = node_pit[from_nodes, TINIT] + df_dm = - cp[mask] * (t_out - t_in) + hc_pit[mask, LOAD_VEC_BRANCHES] = - consumer_array[mask, cls.QEXT] + df_dm * hc_pit[mask, MDOTINIT] + hc_pit[mask, JAC_DERIV_DM] = df_dm + + @classmethod + def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') + mask = consumer_array[:, cls.MODE] == cls.MF_DT + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + q_ext = cp[mask] * consumer_array[mask, cls.MASS] * consumer_array[mask, cls.DELTAT] + hc_pit[mask, QEXT] = q_ext + + mask = consumer_array[:, cls.MODE] == cls.MF_TR + if np.any(mask): + cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) + t_in = node_pit[from_nodes, TINIT] + t_out = hc_pit[mask, TOUTINIT] + q_ext = cp[mask] * consumer_array[mask, cls.MASS] * (t_in - t_out) + hc_pit[mask, QEXT] = q_ext + + @classmethod + def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): + f, t = idx_lookups[cls.table_name()] + hc_pit = branch_pit[f:t, :] + consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') + + # Any MODE where TRETURN is given + mask = np.isin(consumer_array[:, cls.MODE], [cls.MF_TR, cls.QE_TR]) + if np.any(mask): + hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0 + hc_pit[mask, JAC_DERIV_DTOUT] = -1 + hc_pit[mask, JAC_DERIV_DT] = 0 + hc_pit[mask, TOUTINIT] = consumer_array[mask, cls.TRETURN] @classmethod def get_component_input(cls): @@ -173,16 +199,9 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), - ("from_junction", "u4"), - ("to_junction", "u4"), - ("qext_w", "f8"), - ("controlled_mdot_kg_per_s", "f8"), - ("deltat_k", "f8"), - ("treturn_k", "f8"), - ("diameter_m", "f8"), - ("in_service", "bool"), - ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), + ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), + ("in_service", "bool"), ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -197,14 +216,12 @@ def get_result_table(cls, net): :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"] + 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"] + 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 @classmethod @@ -224,5 +241,5 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals(net, branch_results, required_results_hyd, - required_results_ht, cls.table_name(), mode) + extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, + cls.table_name(), mode) diff --git a/src/pandapipes/component_models/junction_component.py b/src/pandapipes/component_models/junction_component.py index 2f0f77ed5..67cbcd14a 100644 --- a/src/pandapipes/component_models/junction_component.py +++ b/src/pandapipes/component_models/junction_component.py @@ -107,7 +107,7 @@ def extract_results(cls, net, options, branch_results, mode): f, t = get_lookup(net, "node", "from_to")[cls.table_name()] junction_pit = net["_pit"]["node"][f:t, :] - if mode in ["hydraulics", "all"]: + if mode in ["hydraulics", "sequential", "bidirectional"]: junctions_connected_hydraulic = get_lookup(net, "node", "active_hydraulics")[f:t] if np.any(junction_pit[junctions_connected_hydraulic, PINIT] < 0): @@ -119,7 +119,7 @@ def extract_results(cls, net, options, branch_results, mode): # if mode == "hydraulics": # res_table["t_k"].values[junctions_connected_hydraulic] = junction_pit[:, TINIT] # - # if mode in ["heat", "all"]: + # if mode in ["heat", "sequential", "bidirectional]: # junctions_connected_ht = get_lookup(net, "node", "active_heat_transfer")[f:t] # res_table["t_k"].values[junctions_connected_ht] = junction_pit[:, TINIT] res_table["p_bar"].values[:] = junction_pit[:, PINIT] diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 3492b6c79..2175c6999 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -13,7 +13,7 @@ from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \ MDOTINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC from pandapipes.idx_node import PINIT, TINIT as TINIT_NODE, PAMB -from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup +from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup, get_net_option from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \ extract_branch_results_without_internals @@ -122,6 +122,8 @@ def create_pit_branch_entries(cls, net, branch_pit): set_entry_check_repeat( pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals) + nan_mask = np.isnan(pipe_pit[:, TEXT]) + pipe_pit[nan_mask, TEXT] = get_net_option(net, 'ambient_temperature') pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4 pipe_pit[:, MDOTINIT] *= pipe_pit[:, AREA] * get_fluid(net).get_density(NORMAL_TEMPERATURE) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index f3edbcb94..e423fa5ff 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -182,7 +182,7 @@ def get_net_params(net, stored_data): net_params["t_sutherland"] = net_data.at[0, "TS"] net_params["t0_sutherland"] = net_data.at[0, "T0"] net_params["calculate_temp"] = str(net_data.at[0, "TEMPCALC"]) == "J" - pp_calc_mode = "all" if net_params["calculate_temp"] else "hydraulics" + pp_calc_mode = "sequential" if net_params["calculate_temp"] else "hydraulics" pandapipes.set_user_pf_options(net, mode=pp_calc_mode) net_params["medium_temp_C"] = net_data.at[0, "TEMP"] net_params["medium_temp_K"] = net_data.at[0, "TEMP"] + 273.15 diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index bf05b253a..55c8ac8ef 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,13 +4,12 @@ import numpy as np import pandas as pd -from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ - _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ - _add_multiple_branch_geodata, _check_branch_element, _check_multiple_branch_elements +from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, _check_node_element, \ + _check_multiple_node_elements, _set_multiple_entries, _add_multiple_branch_geodata, _check_branch_element, \ + _check_multiple_branch_elements -from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \ - HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, \ - Compressor, MassStorage +from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, HeatExchanger, Valve, \ + CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, Compressor, MassStorage from pandapipes.component_models.component_toolbox import add_new_component from pandapipes.component_models.flow_control_component import FlowControlComponent from pandapipes.component_models.heat_consumer_component import HeatConsumer @@ -18,8 +17,7 @@ from pandapipes.properties import call_lib from pandapipes.properties.fluids import Fluid, _add_fluid_to_net from pandapipes.std_types.std_type_class import regression_function, PumpStdType -from pandapipes.std_types.std_types import add_basic_std_types, create_pump_std_type, \ - load_std_type +from pandapipes.std_types.std_types import add_basic_std_types, create_pump_std_type, load_std_type try: import pandaplan.core.pplog as logging @@ -67,8 +65,8 @@ def create_empty_network(name="", fluid=None, add_stdtypes=True): return net -def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, - type="junction", geodata=None, **kwargs): +def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, type="junction", + geodata=None, **kwargs): """ Adds one junction in table net["junction"]. Junctions are the nodes of the network that all other elements connect to. @@ -119,8 +117,8 @@ def create_junction(net, pn_bar, tfluid_k, height_m=0, name=None, index=None, in return index -def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='sink', **kwargs): +def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='sink', + **kwargs): """ Adds one sink in table net["sink"]. @@ -162,8 +160,8 @@ def create_sink(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, return index -def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='source', **kwargs): +def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='source', + **kwargs): """ Adds one source in table net["source"]. @@ -206,9 +204,8 @@ def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=Non return index -def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_stored_kg=0., - max_m_stored_kg=np.inf, scaling=1., name=None, index=None, - in_service=True, type="mass_storage", **kwargs): +def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_stored_kg=0., max_m_stored_kg=np.inf, + scaling=1., name=None, index=None, in_service=True, type="mass_storage", **kwargs): """ Adds one storage entry in table net["mass_storage"]. Not suitable for thermal storage tanks. @@ -262,17 +259,16 @@ def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_ index = _get_index_with_check(net, "mass_storage", index) - cols = ["name", "junction", "mdot_kg_per_s", "scaling", "init_m_stored_kg", "min_m_stored_kg", - "max_m_stored_kg", "in_service", "type"] - vals = [name, junction, mdot_kg_per_s, scaling, init_m_stored_kg, min_m_stored_kg, - max_m_stored_kg, bool(in_service), type] + cols = ["name", "junction", "mdot_kg_per_s", "scaling", "init_m_stored_kg", "min_m_stored_kg", "max_m_stored_kg", + "in_service", "type"] + vals = [name, junction, mdot_kg_per_s, scaling, init_m_stored_kg, min_m_stored_kg, max_m_stored_kg, + bool(in_service), type] _set_entries(net, "mass_storage", index, **dict(zip(cols, vals)), **kwargs) return index -def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, in_service=True, - index=None, **kwargs): +def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, in_service=True, index=None, **kwargs): """ Creates an external grid and adds it to the table net["ext_grid"]. It transfers the junction that it is connected to into a node with fixed value for either pressure, temperature or both @@ -326,8 +322,8 @@ def create_ext_grid(net, junction, p_bar=None, t_k=None, type="auto", name=None, return index -def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, loss_coefficient=0, - name=None, index=None, in_service=True, type="heat_exchanger", **kwargs): +def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, loss_coefficient=0, name=None, + index=None, in_service=True, type="heat_exchanger", **kwargs): """ Creates a heat exchanger element in net["heat_exchanger"] from heat exchanger parameters. @@ -369,17 +365,16 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l index = _get_index_with_check(net, "heat_exchanger", index, "heat exchanger") _check_branch(net, "Heat exchanger", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "qext_w": qext_w, "loss_coefficient": loss_coefficient, - "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "qext_w": qext_w, "loss_coefficient": loss_coefficient, "in_service": bool(in_service), "type": type} _set_entries(net, "heat_exchanger", index, **v, **kwargs) return index -def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, - geodata=None, in_service=True, type="pipe", **kwargs): +def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, + alpha_w_per_m2k=0., qext_w=0., text_k=None, name=None, index=None, geodata=None, in_service=True, + type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -403,10 +398,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 - :param text_k: Ambient temperature of pipe in [K] - :type text_k: float, default 293 :param qext_w: External heat feed-in to the pipe in [W] :type qext_w: float, default 0 + :param text_k: Ambient temperature of pipe in [K] + :type text_k: float, default None, will be set equal to the net ambient temperature :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -437,12 +432,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, _check_std_type(net, std_type, "pipe", "create_pipe") pipe_parameter = load_std_type(net, std_type, "pipe") - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": std_type, "length_km": length_km, - "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w, - "text_k": text_k} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, + "length_km": length_km, "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, + "in_service": bool(in_service), "type": type, "qext_w": qext_w, "text_k": text_k} _set_entries(net, "pipe", index, **v, **kwargs) if geodata is not None: @@ -451,10 +444,9 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, return index -def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, - qext_w=0., name=None, index=None, geodata=None, in_service=True, - type="pipe", **kwargs): +def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, + sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -510,11 +502,10 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam index = _get_index_with_check(net, "pipe", index) _check_branch(net, "Pipe", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": bool(in_service), - "type": type, "qext_w": qext_w, "text_k": text_k} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": None, + "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "loss_coefficient": loss_coefficient, + "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": bool(in_service), "type": type, + "qext_w": qext_w, "text_k": text_k} if 'std_type' in kwargs: raise UserWarning('you have defined a std_type, however, using this function you can only ' 'create a pipe setting specific, individual parameters. If you want to ' @@ -527,8 +518,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam return index -def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_coefficient=0, - name=None, index=None, type='valve', **kwargs): +def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_coefficient=0, name=None, index=None, + type='valve', **kwargs): """ Creates a valve element in net["valve"] from valve parameters. @@ -566,16 +557,15 @@ def create_valve(net, from_junction, to_junction, diameter_m, opened=True, loss_ index = _get_index_with_check(net, "valve", index) _check_branch(net, "Valve", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "opened": opened, "loss_coefficient": loss_coefficient, - "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "opened": opened, "loss_coefficient": loss_coefficient, "type": type} _set_entries(net, "valve", index, **v, **kwargs) return index -def create_pump(net, from_junction, to_junction, std_type, name=None, index=None, in_service=True, - type="pump", **kwargs): +def create_pump(net, from_junction, to_junction, std_type, name=None, index=None, in_service=True, type="pump", + **kwargs): """ Adds one pump in table net["pump"]. @@ -614,17 +604,16 @@ def create_pump(net, from_junction, to_junction, std_type, name=None, index=None _check_branch(net, "Pump", index, from_junction, to_junction) _check_std_type(net, std_type, "pump", "create_pump") - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": std_type, "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, + "in_service": bool(in_service), "type": type} _set_entries(net, "pump", index, **v, **kwargs) return index -def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_name, - pressure_list=None, flowrate_list=None, reg_polynomial_degree=None, - poly_coefficents=None, name=None, index=None, in_service=True, - type="pump", **kwargs): +def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_name, pressure_list=None, + flowrate_list=None, reg_polynomial_degree=None, poly_coefficents=None, name=None, + index=None, in_service=True, type="pump", **kwargs): """ Adds one pump in table net["pump"]. @@ -685,8 +674,7 @@ def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_na index = _get_index_with_check(net, "pump", index) _check_branch(net, "Pump", index, from_junction, to_junction) - if pressure_list is not None and flowrate_list is not None \ - and reg_polynomial_degree is not None: + if pressure_list is not None and flowrate_list is not None and reg_polynomial_degree is not None: reg_par = regression_function(flowrate_list, pressure_list, reg_polynomial_degree) pump = PumpStdType(new_std_type_name, reg_par) create_pump_std_type(net, new_std_type_name, pump) @@ -694,16 +682,15 @@ def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_na pump = PumpStdType(new_std_type_name, poly_coefficents) create_pump_std_type(net, new_std_type_name, pump) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "std_type": new_std_type_name, "in_service": bool(in_service), "type": type} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": new_std_type_name, + "in_service": bool(in_service), "type": type} _set_entries(net, "pump", index, **v, **kwargs) return index -def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_bar, plift_bar, - t_flow_k=None, type="auto", name=None, index=None, - in_service=True, **kwargs): +def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_bar, plift_bar, t_flow_k=None, + type="auto", name=None, index=None, in_service=True, **kwargs): """ Adds one circulation pump with a constant pressure lift in table net["circ_pump_pressure"]. \n A circulation pump is a component that sets the pressure at its outlet (flow junction) and @@ -755,24 +742,20 @@ def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_ add_new_component(net, CirculationPumpPressure) - index = _get_index_with_check(net, "circ_pump_pressure", index, - name="circulation pump with constant pressure") - _check_branch(net, "circulation pump with constant pressure", index, return_junction, - flow_junction) + index = _get_index_with_check(net, "circ_pump_pressure", index, name="circulation pump with constant pressure") + _check_branch(net, "circulation pump with constant pressure", index, return_junction, flow_junction) type = _auto_ext_grid_type(p_flow_bar, t_flow_k, type, CirculationPumpPressure) - v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, - "p_flow_bar": p_flow_bar, "t_flow_k": t_flow_k, "plift_bar": plift_bar, "type": type, - "in_service": bool(in_service)} + v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, "p_flow_bar": p_flow_bar, + "t_flow_k": t_flow_k, "plift_bar": plift_bar, "type": type, "in_service": bool(in_service)} _set_entries(net, "circ_pump_pressure", index, **v, **kwargs) return index -def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow_bar, - mdot_flow_kg_per_s, t_flow_k=None, type="auto", name=None, - index=None, in_service=True, **kwargs): +def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow_bar, mdot_flow_kg_per_s, t_flow_k=None, + type="auto", name=None, index=None, in_service=True, **kwargs): """ Adds one circulation pump with a constant mass flow in table net["circ_pump_mass"].\n A circulation pump is a component that sets the pressure at its outlet (flow junction) and @@ -823,23 +806,20 @@ def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow add_new_component(net, CirculationPumpMass) - index = _get_index_with_check(net, "circ_pump_mass", index, - name="circulation pump with constant mass flow") - _check_branch(net, "circulation pump with constant mass flow", index, return_junction, - flow_junction) + index = _get_index_with_check(net, "circ_pump_mass", index, name="circulation pump with constant mass flow") + _check_branch(net, "circulation pump with constant mass flow", index, return_junction, flow_junction) type = _auto_ext_grid_type(p_flow_bar, t_flow_k, type, CirculationPumpMass) - v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, - "p_flow_bar": p_flow_bar, "t_flow_k": t_flow_k, "mdot_flow_kg_per_s": mdot_flow_kg_per_s, - "type": type, "in_service": bool(in_service)} + v = {"name": name, "return_junction": return_junction, "flow_junction": flow_junction, "p_flow_bar": p_flow_bar, + "t_flow_k": t_flow_k, "mdot_flow_kg_per_s": mdot_flow_kg_per_s, "type": type, "in_service": bool(in_service)} _set_entries(net, "circ_pump_mass", index, **v, **kwargs) return index -def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None, index=None, - in_service=True, **kwargs): +def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None, index=None, in_service=True, + **kwargs): """Adds a compressor with relative pressure lift to net["compressor"]. The outlet (absolute) pressure is calculated by (p_in + p_ambient) * pressure_ratio. For @@ -876,16 +856,16 @@ def create_compressor(net, from_junction, to_junction, pressure_ratio, name=None index = _get_index_with_check(net, "compressor", index) _check_branch(net, "Compressor", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "pressure_ratio": pressure_ratio, "in_service": bool(in_service)} + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "pressure_ratio": pressure_ratio, + "in_service": bool(in_service)} _set_entries(net, "compressor", index, **v, **kwargs) return index -def create_pressure_control(net, from_junction, to_junction, controlled_junction, controlled_p_bar, - control_active=True, loss_coefficient=0., name=None, index=None, - in_service=True, type="pressure_control", **kwargs): +def create_pressure_control(net, from_junction, to_junction, controlled_junction, controlled_p_bar, control_active=True, + loss_coefficient=0., name=None, index=None, in_service=True, type="pressure_control", + **kwargs): """Adds one pressure control that enforces a pressure at a specific junction. The pressure control unit creates a pressure drop / lift between the 'from' and the 'to' @@ -949,11 +929,10 @@ def create_pressure_control(net, from_junction, to_junction, controlled_junction # check if junctions exist to attach the pump to _check_branch(net, "PressureControl", index, from_junction, to_junction) - _set_entries(net, "press_control", index, name=name, from_junction=from_junction, - to_junction=to_junction, controlled_junction=controlled_junction, - control_active=bool(control_active), loss_coefficient=loss_coefficient, - controlled_p_bar=controlled_p_bar, in_service=bool(in_service), type=type, - **kwargs) + _set_entries(net, "press_control", index, name=name, from_junction=from_junction, to_junction=to_junction, + controlled_junction=controlled_junction, control_active=bool(control_active), + loss_coefficient=loss_coefficient, controlled_p_bar=controlled_p_bar, in_service=bool(in_service), + type=type, **kwargs) if controlled_junction != from_junction and controlled_junction != to_junction: logger.warning("The pressure controller %d controls the pressure at a junction that it is " @@ -964,9 +943,8 @@ def create_pressure_control(net, from_junction, to_junction, controlled_junction return index -def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_s, diameter_m, - control_active=True, name=None, index=None, in_service=True, type="fc", - **kwargs): +def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_s, diameter_m, control_active=True, + name=None, index=None, in_service=True, type="fc", **kwargs): """ Adds one flow control with a constant mass flow in table net["flow_control"]. @@ -1012,17 +990,16 @@ def create_flow_control(net, from_junction, to_junction, controlled_mdot_kg_per_ # check if junctions exist to attach the pump to _check_branch(net, "FlowControl", index, from_junction, to_junction) - _set_entries(net, "flow_control", index, name=name, from_junction=from_junction, - to_junction=to_junction, controlled_mdot_kg_per_s=controlled_mdot_kg_per_s, - diameter_m=diameter_m, control_active=bool(control_active), - in_service=bool(in_service), type=type, **kwargs) + _set_entries(net, "flow_control", index, name=name, from_junction=from_junction, to_junction=to_junction, + controlled_mdot_kg_per_s=controlled_mdot_kg_per_s, diameter_m=diameter_m, + control_active=bool(control_active), in_service=bool(in_service), type=type, **kwargs) return index -def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=None, - controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, name=None, - index=None, in_service=True, type="heat_consumer", **kwargs): +def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=None, controlled_mdot_kg_per_s=None, + deltat_k=None, treturn_k=None, name=None, index=None, in_service=True, type="heat_consumer", + **kwargs): """ Creates a heat consumer element in net["heat_consumer"] from heat consumer parameters. @@ -1064,33 +1041,28 @@ def create_heat_consumer(net, from_junction, to_junction, diameter_m, qext_w=Non >>> create_heat_consumer(net,from_junction=0, to_junction=1, diameter_m=40e-3, qext_w=20000, >>> controlled_mdot_kg_per_s=0.4, name="heat_consumer1") """ - if deltat_k is not None or treturn_k is not None: - raise NotImplementedError("The models for consumers with fixed temperature difference or " - "fixed return temperature are not implemented yet.") - if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) - + (treturn_k is None) != 2): + if ((controlled_mdot_kg_per_s is None) + (qext_w is None) + (deltat_k is None) + (treturn_k is None) != 2): raise AttributeError(r"Define exactly two varibales from 'controlled_mdot_kg_per_s', " - r"'qext_w' and 'deltat_k' or 'treturn_k' different from None") + r"'qext_w' and 'deltat_k' or 'treturn_k' different from None.") + if deltat_k is not None and treturn_k is not None: raise AttributeError(r"It is not possible to set both 'deltat_k' and 'treturn_k', as the " r"flow temperature is independent of the heat consumer model.") - add_new_component(net, HeatConsumer) index = _get_index_with_check(net, "heat_consumer", index, "heat consumer") _check_branch(net, "Heat consumer", index, from_junction, to_junction) - v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, - "diameter_m": diameter_m, "qext_w": qext_w, - "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "diameter_m": diameter_m, + "qext_w": qext_w, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_entries(net, "heat_consumer", index, **v, **kwargs) return index -def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, index=None, - in_service=True, type="junction", geodata=None, **kwargs): +def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, index=None, in_service=True, + type="junction", geodata=None, **kwargs): """ Convenience function for creating many junctions at once. Parameter 'nr_junctions' specifies \ the number of junctions created. Other parameters may be either arrays of length 'nr_junctions'\ @@ -1131,8 +1103,8 @@ def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, add_new_component(net, Junction) index = _get_multiple_index_with_check(net, "junction", index, nr_junctions) - entries = {"pn_bar": pn_bar, "type": type, "tfluid_k": tfluid_k, "height_m": height_m, - "in_service": in_service, "name": name} + entries = {"pn_bar": pn_bar, "type": type, "tfluid_k": tfluid_k, "height_m": height_m, "in_service": in_service, + "name": name} _set_multiple_entries(net, "junction", index, **entries, **kwargs) if geodata is not None: @@ -1146,8 +1118,8 @@ def create_junctions(net, nr_junctions, pn_bar, tfluid_k, height_m=0, name=None, return index -def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, - type='sink', **kwargs): +def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='sink', + **kwargs): """ Convenience function for creating many sinks at once. Parameter 'junctions' must be an array \ of the desired length. Other parameters may be either arrays of the same length or single \ @@ -1184,15 +1156,15 @@ def create_sinks(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=Non _check_multiple_junction_elements(net, junctions) index = _get_multiple_index_with_check(net, "sink", index, len(junctions)) - entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, "in_service": in_service, + "name": name, "type": type} _set_multiple_entries(net, "sink", index, **entries, **kwargs) return index -def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, - in_service=True, type='source', **kwargs): +def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=None, in_service=True, type='source', + **kwargs): """ Convenience function for creating many sources at once. Parameter 'junctions' must be an array \ of the desired length. Other parameters may be either arrays of the same length or single \ @@ -1229,15 +1201,14 @@ def create_sources(net, junctions, mdot_kg_per_s, scaling=1., name=None, index=N _check_multiple_junction_elements(net, junctions) index = _get_multiple_index_with_check(net, "source", index, len(junctions)) - entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "mdot_kg_per_s": mdot_kg_per_s, "scaling": scaling, "in_service": in_service, + "name": name, "type": type} _set_multiple_entries(net, "source", index, **entries, **kwargs) return index -def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, index=None, - type="auto", **kwargs): +def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, index=None, type="auto", **kwargs): """ Convenience function for creating many external grids at once. Parameter 'junctions' must be an\ array of the desired length. Other parameters may be either arrays of the same length or single\ @@ -1286,16 +1257,15 @@ def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, ind type = _auto_ext_grid_types(p_bar, t_k, type, ExtGrid) - entries = {"junction": junctions, "p_bar": p_bar, "t_k": t_k, - "in_service": in_service, "name": name, "type": type} + entries = {"junction": junctions, "p_bar": p_bar, "t_k": t_k, "in_service": in_service, "name": name, "type": type} _set_multiple_entries(net, "ext_grid", index, **entries, **kwargs) return index -def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., - name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): +def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, + alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, + type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1361,12 +1331,10 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. _check_std_type(net, std_type, "pipe", "create_pipes") pipe_parameters = load_std_type(net, std_type, "pipe") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "std_type": std_type, "length_km": length_km, - "diameter_m": pipe_parameters["inner_diameter_mm"] / 1000, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, - "text_k": text_k} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": std_type, + "length_km": length_km, "diameter_m": pipe_parameters["inner_diameter_mm"] / 1000, "k_mm": k_mm, + "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, + "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} _set_multiple_entries(net, "pipe", index, **entries, **kwargs) if geodata is not None: @@ -1374,10 +1342,9 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. return index -def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, - loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293, - qext_w=0., name=None, index=None, geodata=None, in_service=True, - type="pipe", **kwargs): +def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, + sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1439,11 +1406,10 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d index = _get_multiple_index_with_check(net, "pipe", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "pipe") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, - "loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k, - "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, - "text_k": text_k} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, + "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, "loss_coefficient": loss_coefficient, + "alpha_w_per_m2k": alpha_w_per_m2k, "sections": sections, "in_service": in_service, "type": type, + "qext_w": qext_w, "text_k": text_k} _set_multiple_entries(net, "pipe", index, **entries, **kwargs) if geodata is not None: @@ -1451,8 +1417,8 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d return index -def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, loss_coefficient=0, - name=None, index=None, type='valve', **kwargs): +def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, loss_coefficient=0, name=None, index=None, + type='valve', **kwargs): """ Convenience function for creating many valves at once. Parameters 'from_junctions' and \ 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the \ @@ -1495,17 +1461,16 @@ def create_valves(net, from_junctions, to_junctions, diameter_m, opened=True, lo index = _get_multiple_index_with_check(net, "valve", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "valve") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "opened": opened, "loss_coefficient": loss_coefficient, - "type": type} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "opened": opened, "loss_coefficient": loss_coefficient, "type": type} _set_multiple_entries(net, "valve", index, **entries, **kwargs) return index -def create_pressure_controls(net, from_junctions, to_junctions, controlled_junctions, - controlled_p_bar, control_active=True, loss_coefficient=0., name=None, - index=None, in_service=True, type="pressure_control", **kwargs): +def create_pressure_controls(net, from_junctions, to_junctions, controlled_junctions, controlled_p_bar, + control_active=True, loss_coefficient=0., name=None, index=None, in_service=True, + type="pressure_control", **kwargs): """ Convenience function for creating many pressure controls at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1568,12 +1533,11 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "controlled_junction": controlled_junctions, "controlled_p_bar": controlled_p_bar, - "control_active": control_active, "loss_coefficient": loss_coefficient, - "in_service": in_service, "type": type} + "control_active": control_active, "loss_coefficient": loss_coefficient, "in_service": in_service, + "type": type} _set_multiple_entries(net, "press_control", index, **entries, **kwargs) - controlled_elsewhere = (controlled_junctions != from_junctions) \ - & (controlled_junctions != to_junctions) + controlled_elsewhere = (controlled_junctions != from_junctions) & (controlled_junctions != to_junctions) if np.any(controlled_elsewhere): controllers_warn = index[controlled_elsewhere] logger.warning("The pressure controllers %s control the pressure at junctions that they are" @@ -1584,9 +1548,8 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct return index -def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_per_s, diameter_m, - control_active=True, name=None, index=None, in_service=True, type="fc", - **kwargs): +def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_per_s, diameter_m, control_active=True, + name=None, index=None, in_service=True, type="fc", **kwargs): """ Convenience function for creating many flow controls at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1643,9 +1606,8 @@ def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_p return index -def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, - loss_coefficient=0, name=None, index=None, in_service=True, - type="heat_exchanger", **kwargs): +def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, loss_coefficient=0, name=None, + index=None, in_service=True, type="heat_exchanger", **kwargs): """ Convenience function for creating many heat exchangers at once. Parameters 'from_junctions'\ and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\ @@ -1691,17 +1653,16 @@ def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w index = _get_multiple_index_with_check(net, "heat_exchanger", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "heat_exchanger") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "qext_w": qext_w, "loss_coefficient": loss_coefficient, - "in_service": bool(in_service), "type": type} + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "qext_w": qext_w, "loss_coefficient": loss_coefficient, "in_service": bool(in_service), "type": type} _set_multiple_entries(net, "heat_exchanger", index, **entries, **kwargs) return index -def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w=None, - controlled_mdot_kg_per_s=None, deltat_k=None, treturn_k=None, - name=None, index=None, in_service=True, type="heat_consumer", **kwargs): +def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w=None, controlled_mdot_kg_per_s=None, + deltat_k=None, treturn_k=None, name=None, index=None, in_service=True, type="heat_consumer", + **kwargs): """ Creates several heat consumer elements in net["heat_consumer"] from heat consumer parameters. @@ -1744,9 +1705,6 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= >>> create_heat_consumers(net,from_junctions=[0, 3], to_junctions=[1, 5], diameter_m=40e-3, >>> qext_w=20000, controlled_mdot_kg_per_s=[0.5, 0.9]) """ - if np.any(pd.notnull(deltat_k)) or np.any(pd.notnull(treturn_k)): - raise NotImplementedError("The models for consumers with fixed temperature difference or " - "fixed return temperature are not implemented yet.") check_vars = [controlled_mdot_kg_per_s, qext_w, deltat_k, treturn_k] var_sums = np.zeros([4, len(from_junctions)]) for i, cv in enumerate(check_vars): @@ -1764,9 +1722,8 @@ def create_heat_consumers(net, from_junctions, to_junctions, diameter_m, qext_w= index = _get_multiple_index_with_check(net, "heat_consumer", index, len(from_junctions)) _check_branches(net, from_junctions, to_junctions, "heat_consumer") - entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, - "diameter_m": diameter_m, "qext_w": qext_w, - "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, + entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "diameter_m": diameter_m, + "qext_w": qext_w, "controlled_mdot_kg_per_s": controlled_mdot_kg_per_s, "deltat_k": deltat_k, "treturn_k": treturn_k, "in_service": bool(in_service), "type": type} _set_multiple_entries(net, "heat_consumer", index, **entries, **kwargs) return index @@ -1802,13 +1759,11 @@ def _check_junction_element(net, junction): def _check_branch(net, element_name, index, from_junction, to_junction): - return _check_branch_element(net, element_name, index, from_junction, to_junction, - node_name="junction", plural="s") + return _check_branch_element(net, element_name, index, from_junction, to_junction, node_name="junction", plural="s") def _check_branches(net, from_junctions, to_junctions, table): - return _check_multiple_branch_elements(net, from_junctions, to_junctions, table, - node_name="junction", plural="s") + return _check_multiple_branch_elements(net, from_junctions, to_junctions, table, node_name="junction", plural="s") def _check_std_type(net, std_type, table, function_name): @@ -1843,30 +1798,25 @@ def _auto_ext_grid_type(p_bar, t_k, typ, comp): p_null, t_null = p_bar is None or np.isnan(p_bar), t_k is None or np.isnan(t_k) if p_null and t_null: - raise UserWarning("For component %s, either pressure or temperature must be defined!" - % comp.__name__) + raise UserWarning("For component %s, either pressure or temperature must be defined!" % comp.__name__) if typ not in ALLOWED_EG_TYPES: logger.warning("The type for component %s was %s, but must be one of the following for " "correct model implementation: %s." % (comp.__name__, typ, ALLOWED_EG_TYPES)) if typ not in ["t", "auto"] and p_null: - raise UserWarning("The type %s for component %s requires a pressure as input!" - % (typ, comp.__name__)) + raise UserWarning("The type %s for component %s requires a pressure as input!" % (typ, comp.__name__)) if typ not in ["p", "auto"] and t_null: - raise UserWarning("The type %s for component %s requires a temperature as input!" - % (typ, comp.__name__)) + raise UserWarning("The type %s for component %s requires a temperature as input!" % (typ, comp.__name__)) if typ != "auto" and "p" not in typ and not p_null: logger.warning("For component %s you gave a value for p, although the component is not of " - "'p'-type (type is %s), i.e. this value is probably neglected internally." - % (comp, typ)) + "'p'-type (type is %s), i.e. this value is probably neglected internally." % (comp, typ)) if typ != "auto" and "t" not in typ and not t_null: logger.warning("For component %s you gave a value for t, although the component is not of " - "'t'-type (type is %s), i.e. this value is probably neglected internally." - % (comp, typ)) + "'t'-type (type is %s), i.e. this value is probably neglected internally." % (comp, typ)) if typ == "tp": logger.warning("The type 'tp' is replaced by type 'pt' (might be mistaken internally).") @@ -1910,8 +1860,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): if not any([p_arr, t_arr, typ_arr]): return _auto_ext_grid_type(p_bar, t_k, typ, comp) else: - lengths = np.array([len(arr) for arr, it in zip([p_bar, t_k, typ], [p_arr, t_arr, typ_arr]) - if it]) + lengths = np.array([len(arr) for arr, it in zip([p_bar, t_k, typ], [p_arr, t_arr, typ_arr]) if it]) if not np.array_equal(lengths[1:], lengths[:-1]): raise UserWarning("The arrays for p_bar, t_k and type must have equal length!") length = lengths[0] @@ -1940,8 +1889,8 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): pos_not_allowed_types = np.where(not_allowed_types) overview = pd.DataFrame({"Position": pos_not_allowed_types, "Type": typ_not_allowed_types}) logger.warning("Please check the following types for component %s, as they must be one of " - "the following for correct model implementation: %s. \n%s" - % (comp.__name__, ALLOWED_EG_TYPES, overview)) + "the following for correct model implementation: %s. \n%s" % ( + comp.__name__, ALLOWED_EG_TYPES, overview)) p_types = np.isin(typ, [tp for tp in ALLOWED_EG_TYPES if tp not in ["t", "auto"]]) t_types = np.isin(typ, [tp for tp in ALLOWED_EG_TYPES if tp not in ["p", "auto"]]) @@ -1964,8 +1913,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): ununsed_p = ~auto_types & ~p_null & ~p_types if np.any(ununsed_p): - overview = pd.DataFrame({"Positions": np.where(ununsed_p)[0], - "Type": np.array(typ)[ununsed_p], + overview = pd.DataFrame({"Positions": np.where(ununsed_p)[0], "Type": np.array(typ)[ununsed_p], "p_value": np.array(p_bar)[ununsed_p]}) logger.warning("For component %s you gave a value for p in some cases, although the " "respective components are not of 'p'-type, i.e. the given values are " @@ -1973,8 +1921,7 @@ def _auto_ext_grid_types(p_bar, t_k, typ, comp): ununsed_t = ~auto_types & ~t_null & ~t_types if np.any(ununsed_t): - overview = pd.DataFrame({"Positions": np.where(ununsed_t)[0], - "Type": np.array(typ)[ununsed_t], + overview = pd.DataFrame({"Positions": np.where(ununsed_t)[0], "Type": np.array(typ)[ununsed_t], "t_value": np.array(p_bar)[ununsed_t]}) logger.warning("For component %s you gave a value for t in some cases, although the " "respective components are not of 't'-type, i.e. the given values are " diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 5cadb5524..6d9ba63e0 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -4,7 +4,7 @@ from pandapipes.constants import P_CONVERSION, GRAVITATION_CONSTANT, NORMAL_PRESSURE, \ NORMAL_TEMPERATURE from pandapipes.idx_branch import LENGTH, LAMBDA, D, LOSS_COEFFICIENT as LC, PL, AREA, \ - MDOTINIT, FROM_NODE, TO_NODE + MDOTINIT, FROM_NODE, TO_NODE, TOUTINIT from pandapipes.idx_node import HEIGHT, PAMB, PINIT, TINIT as TINIT_NODE try: @@ -67,8 +67,7 @@ def derivatives_hydraulic_comp_numba(node_pit, branch_pit, lambda_, der_lambda, p_sum = p_init_i_abs[i] + p_init_i1_abs[i] p_sum_div = np.divide(1, p_sum) fn = from_nodes[i] - tn = to_nodes[i] - tm = (node_pit[fn, TINIT_NODE] + node_pit[tn, TINIT_NODE]) / 2 + tm = (node_pit[fn, TINIT_NODE] + branch_pit[i][TOUTINIT]) / 2 const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION friction_term = np.divide(lambda_[i] * branch_pit[i][LENGTH], branch_pit[i][D]) + \ diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index 78d33e2e8..f6b16815e 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -34,10 +34,10 @@ logger = logging.getLogger(__name__) default_options = {"friction_model": "nikuradse", "tol_p": 1e-5, "tol_m": 1e-5, - "tol_T": 1e-3, "tol_res": 1e-3, "max_iter_hyd": 10, "max_iter_therm": 10, + "tol_T": 1e-3, "tol_res": 1e-3, "max_iter_hyd": 10, "max_iter_therm": 10, "max_iter_bidirect": 10, "error_flag": False, "alpha": 1, "nonlinear_method": "constant", "mode": "hydraulics", - "ambient_temperature": 293, "check_connectivity": True, + "ambient_temperature": 293.15, "check_connectivity": True, "max_iter_colebrook": 10, "only_update_hydraulic_matrix": False, "reuse_internal_data": False, "use_numba": True, "quit_on_inconsistency_connectivity": False, "calc_compression_power": True} @@ -247,8 +247,8 @@ def init_options(net, local_parameters): automatically with respect to the convergence behaviour. - **mode** (str): "hydraulics" - Define the calculation mode: what shall be calculated - \ - solely hydraulics ('hydraulics'), solely heat transfer('heat') or both combined \ - ('all'). + solely hydraulics ('hydraulics'), solely heat transfer('heat') or both combined sequentially \ + ('sequential') or bidirectionally ('bidirectional'). - **only_update_hydraulic_matrix** (bool): False - If True, the system matrix is not \ created in every iteration, but only the data is updated according to a lookup that\ @@ -292,6 +292,7 @@ def init_options(net, local_parameters): # the third layer is the user defined pipeflow options if "user_pf_options" in net and len(net.user_pf_options) > 0: opts = _iteration_check(net.user_pf_options) + opts = _check_mode(opts) net["_options"].update(opts) @@ -305,6 +306,7 @@ def init_options(net, local_parameters): params[k] = v opts = _iteration_check(local_parameters["kwargs"]) + opts = _check_mode(opts) params.update(opts) net["_options"].update(params) net["_options"]["fluid"] = get_fluid(net).name @@ -322,7 +324,7 @@ def _iteration_check(opts): iter_defined = False params = dict() if 'iter' in opts: - params['max_iter_hyd'] = params['max_iter_therm'] = opts["iter"] + params['max_iter_hyd'] = params['max_iter_therm'] = params['max_iter_bidirect'] = opts["iter"] iter_defined = True if 'max_iter_hyd' in opts: max_iter_hyd = opts["max_iter_hyd"] @@ -334,9 +336,22 @@ def _iteration_check(opts): if iter_defined: logger.info("You defined 'iter' and 'max_iter_therm. " "'max_iter_therm' will overwrite 'iter'") params['max_iter_therm'] = max_iter_therm + if 'max_iter_bidirect' in opts: + max_iter_bidirect = opts["max_iter_bidirect"] + if iter_defined: logger.info("You defined 'iter' and 'max_iter_bidirect. " + "'max_iter_bidirect' will overwrite 'iter'") + params['max_iter_bidirect'] = max_iter_bidirect opts.update(params) return opts +def _check_mode(opts): + opts = copy.deepcopy(opts) + if 'mode' in opts and opts['mode'] == 'all': + logger.warning("mode 'all' is deprecated and will be removed in a future release. " + "Use 'sequential' or 'bidirectional' instead. " + "For now 'all' is set equal to 'sequential'.") + opts['mode'] = 'sequential' + return opts def create_internal_results(net): """ @@ -383,8 +398,12 @@ def initialize_pit(net): comp.create_pit_node_entries(net, pit["node"]) comp.create_pit_branch_entries(net, pit["branch"]) comp.create_component_array(net, pit["components"]) - return pit["node"], pit["branch"] + if len(pit["node"]) == 0: + logger.warning("There are no nodes defined. " + "You need at least one node! " + "Without any nodes, you are not able to conduct a pipeflow!") + return def create_empty_pit(net): """ @@ -469,7 +488,7 @@ def create_lookups(net): "internal_nodes_lookup": internal_nodes_lookup} -def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): +def identify_active_nodes_branches(net, hydraulic=True): """ Function that creates the connectivity lookup for nodes and branches. If the option \ "check_connectivity" is set, a full connectivity check is performed based on a sparse matrix \ @@ -493,6 +512,10 @@ def identify_active_nodes_branches(net, branch_pit, node_pit, hydraulic=True): :type hydraulic: bool, default True :return: No output """ + + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] + if hydraulic: # connectivity check for hydraulic simulation if get_net_option(net, "check_connectivity"): @@ -673,7 +696,7 @@ def get_table_index_list(net, pit_array, pit_indices, pit_type="node"): for tbl in tables] -def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): +def reduce_pit(net, mode="hydraulics"): """ Create an internal ("active") pit with all nodes and branches that are actually in_service. This is also done for different lookups (e.g. the from_to indices for this pit and the node index @@ -691,6 +714,10 @@ def reduce_pit(net, node_pit, branch_pit, mode="hydraulics"): :type mode: str, default "hydraulics" :return: No output """ + + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] + active_pit = dict() els = dict() reduced_node_lookup = None diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 5e277608f..0dfaa2c7a 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -2,7 +2,7 @@ from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MDOTINIT, RE, \ - LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA + LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA, TEXT from pandapipes.idx_node import TABLE_IDX as TABLE_IDX_NODE, PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option @@ -21,7 +21,7 @@ def extract_all_results(net, calculation_mode): :param net: pandapipes net for which to extract results into net.res_xy :type net: pandapipesNet - :param net: mode of the simulation (e.g. "hydraulics" or "heat" or "all") + :param net: mode of the simulation (e.g. "hydraulics" or "heat" or "sequential" or "bidirectional") :type net: str :return: No output @@ -182,7 +182,7 @@ def extract_branch_results_with_internals(net, branch_results, table_name, if result_mode == "hydraulics" and simulation_mode == "heat": continue lookup_name = "hydraulics" - if result_mode == "heat" and simulation_mode in ["heat", "all"]: + if result_mode == "heat" and simulation_mode in ["heat", "sequential", "bidirectional"]: lookup_name = "heat_transfer" comp_connected = get_lookup(net, "branch", "active_" + lookup_name)[f:t] for (res_ext, node_name) in ((res_nodes_from, "from_nodes"), (res_nodes_to, "to_nodes")): @@ -233,7 +233,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul :type required_results_heat: list[tuple] :param table_name: The name of the table that the results should be written to :type table_name: str - :param simulation_mode: simulation mode (e.g. "hydraulics", "heat", "all"); defines whether results from \ + :param simulation_mode: simulation mode (e.g. "hydraulics", "heat", "sequential", "bidirectional"); defines whether results from \ hydraulic or temperature calculation are transferred :type simulation_mode: str :return: No output @@ -243,7 +243,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul f, t = get_lookup(net, "branch", "from_to")[table_name] # extract hydraulic results - if simulation_mode in ["hydraulics", "all"]: + if simulation_mode in ["hydraulics", 'sequential', "bidirectional"]: # lookup for connected branch elements (hydraulic results) comp_connected_hyd = get_lookup(net, "branch", "active_hydraulics")[f:t] for res_name, entry in required_results_hydraulic: @@ -255,7 +255,7 @@ def extract_branch_results_without_internals(net, branch_results, required_resul branch_results[entry][f:t][comp_connected_hyd] # extract heat transfer results - if simulation_mode in ["heat", "all"]: + if simulation_mode in ["heat", 'sequential', "bidirectional"]: # lookup for connected branch elements (heat transfer results) comp_connected_ht = get_lookup(net, "branch", "active_heat_transfer")[f:t] for res_name, entry in required_results_heat: @@ -290,16 +290,19 @@ def extract_results_active_pit(net, mode="hydraulics"): not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] - net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN + amb = get_net_option(net, 'ambient_temperature') + + net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN if mode == "hydraulics" else amb net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN if mode == "hydraulics" else \ + net["_pit"]["branch"][~branches_connected, TEXT] net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols] def consider_heat(mode, results=None): - consider_ = mode in ["heat", "all"] + consider_ = mode in ["heat", 'sequential', 'bidirectional'] if results is None: return consider_ return consider_ and any(r[2] for r in results) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 629c1cd0f..1ef79d2ae 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -10,10 +10,9 @@ from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal -from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, \ - init_options, create_internal_results, write_internal_results, get_lookup, create_lookups, \ - initialize_pit, reduce_pit, set_user_pf_options, init_all_result_tables, \ - identify_active_nodes_branches, PipeflowNotConverged +from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, init_options, \ + create_internal_results, write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, \ + set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, PipeflowNotConverged from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit try: @@ -68,136 +67,147 @@ def pipeflow(net, sol_vec=None, **kwargs): init_all_result_tables(net) create_lookups(net) - node_pit, branch_pit = initialize_pit(net) - if len(node_pit) == 0: - logger.warning("There are no nodes defined. " - "You need at least one node! " - "Without any nodes, you are not able to conduct a pipeflow!") - return + initialize_pit(net) calculation_mode = get_net_option(net, "mode") - calculate_hydraulics = calculation_mode in ["hydraulics", "all"] - calculate_heat = calculation_mode in ["heat", "all"] + calculate_hydraulics = calculation_mode in ["hydraulics", 'sequential'] + calculate_heat = calculation_mode in ["heat", 'sequential'] + calculate_bidrect = calculation_mode == "bidirectional" # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also required to # determine the active node/branch heat transfer lookup - identify_active_nodes_branches(net, branch_pit, node_pit) - - if calculation_mode == "heat": - if not net.user_pf_options["hyd_flag"]: - raise UserWarning("Converged flag not set. Make sure that hydraulic calculation " - "results are available.") - else: - net["_pit"]["node"][:, PINIT] = sol_vec[:len(node_pit)] - net["_pit"]["branch"][:, MDOTINIT] = sol_vec[len(node_pit):] - - if calculate_hydraulics: - reduce_pit(net, node_pit, branch_pit, mode="hydraulics") - hydraulics(net) - if not net.converged: - raise PipeflowNotConverged("The hydraulic calculation did not converge to a solution.") - extract_results_active_pit(net, mode="hydraulics") - - if calculate_heat: - node_pit, branch_pit = net["_pit"]["node"], net["_pit"]["branch"] - identify_active_nodes_branches(net, branch_pit, node_pit, False) - reduce_pit(net, node_pit, branch_pit, mode="heat_transfer") - heat_transfer(net) - if not net.converged: - raise PipeflowNotConverged("The heat transfer calculation did not converge to a " - "solution.") - extract_results_active_pit(net, mode="heat_transfer") - elif not calculate_hydraulics: + identify_active_nodes_branches(net) + + if calculation_mode == 'heat': use_given_hydraulic_results(net, sol_vec) + + if not (calculate_hydraulics | calculate_heat | calculate_bidrect): raise UserWarning("No proper calculation mode chosen.") + elif calculate_bidrect: + bidirectional(net) + else: + if calculate_hydraulics: + hydraulics(net) + if calculate_heat: + heat_transfer(net) extract_all_results(net, calculation_mode) -def hydraulics(net): - max_iter, nonlinear_method, tol_p, tol_m, tol_res = get_net_options( - net, "max_iter_hyd", "nonlinear_method", "tol_p", "tol_m", "tol_res") +def use_given_hydraulic_results(net, sol_vec): + node_pit = net["_pit"]["node"] + branch_pit = net["_pit"]["branch"] - # Start of nonlinear loop - # --------------------------------------------------------------------------------------------- - niter = 0 - create_internal_results(net) - if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: - net["_internal_data"] = dict() + if not net.user_pf_options["hyd_flag"]: + raise UserWarning("Converged flag not set. Make sure that hydraulic calculation " + "results are available.") + else: + node_pit[:, PINIT] = sol_vec[:len(node_pit)] + branch_pit[:, MDOTINIT] = sol_vec[len(node_pit):] - # This branch is used to stop the solver after a specified error tolerance is reached - error_m, error_p, residual_norm = [], [], None +def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): + max_iter, nonlinear_method, tol_res = get_net_options(net, iter_name, "nonlinear_method", "tol_res") + niter = 0 + # This branch is used to stop the solver after a specified error tolerance is reached + errors = {var: [] for var in vars} + diff = {var: [] for var in vars} + create_internal_results(net) + residual_norm = None # This loop is left as soon as the solver converged while not net.converged and niter < max_iter: logger.debug("niter %d" % niter) # solve_hydraulics is where the calculation takes place - m_init, p_init, m_init_old, p_init_old, epsilon = solve_hydraulics(net) + results, residual = funct(net) + residual_norm = linalg.norm(residual / len(residual)) + logger.debug("residual: %s" % residual_norm.round(4)) + pos = np.arange(len(vars) * 2) + results = np.array(results, object) + vals_new = results[pos[::2]] + vals_old = results[pos[1::2]] + for var, val_new, val_old in zip(vars, vals_new, vals_old): + dval = val_new - val_old + diff[var].append(dval.mean()) + errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) + finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, + vals_old=vals_old, vars=vars, pit_names=pit_names, diff=diff) + niter += 1 + write_internal_results(net, **errors) + kwargs = dict() + kwargs['residual_norm_%s' % mode] = residual_norm + kwargs['iterations_%s' % mode] = niter + write_internal_results(net, **kwargs) + log_final_results(net, mode, niter, residual_norm, vars, tols) - # Error estimation & convergence plot - dm_init = np.abs(m_init - m_init_old) - dp_init = np.abs(p_init - p_init_old) - residual_norm = linalg.norm(epsilon) / len(epsilon) - error_m.append(linalg.norm(dm_init) / len(dm_init) if len(dm_init) else 0) - error_p.append(linalg.norm(dp_init / len(dp_init))) +def bidirectional(net): + if get_net_option(net, 'nonlinear_method') == 'std': + set_net_option(net, 'alpha', 0.33) + net.converged = False + if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: + net["_internal_data"] = dict() + vars = ['mdot', 'p', 'TOUT', 'T'] + tol_m, tol_p, tol_T = get_net_options(net, 'tol_m', 'tol_p', 'tol_T') + newton_raphson(net, solve_bidirectional, 'bidirectional', vars, [tol_m, tol_p, tol_T, tol_T], + ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect') + if net.converged: + set_user_pf_options(net, hyd_flag=True) + if not get_net_option(net, "reuse_internal_data"): + net.pop("_internal_data", None) + if not net.converged: + raise PipeflowNotConverged("The bidrectional calculation did not converge to a solution.") - finalize_iteration(net, niter, error_p, error_m, residual_norm, nonlinear_method, tol_p, - tol_m, tol_res, p_init_old, m_init_old) - niter += 1 - write_internal_results(net, iterations=niter, error_p=error_p[niter - 1], - error_m=error_m[niter - 1], residual_norm=residual_norm) +def hydraulics(net): + # Start of nonlinear loop + # --------------------------------------------------------------------------------------------- + net.converged = False + reduce_pit(net, mode="hydraulics") + if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: + net["_internal_data"] = dict() + vars = ['mdot', 'p'] + tol_p, tol_m = get_net_options(net, 'tol_m', 'tol_p') + newton_raphson(net, solve_hydraulics, 'hydraulics', vars, [tol_m, tol_p], ['branch', 'node'], 'max_iter_hyd') if net.converged: set_user_pf_options(net, hyd_flag=True) - log_final_results(net, niter, residual_norm) if not get_net_option(net, "reuse_internal_data"): net.pop("_internal_data", None) + if not net.converged: + raise PipeflowNotConverged("The hydraulic calculation did not converge to a solution.") + extract_results_active_pit(net, mode="hydraulics") + def heat_transfer(net): - max_iter, nonlinear_method, tol_t, tol_res = get_net_options( - net, "max_iter_therm", "nonlinear_method", "tol_T", "tol_res") - # Start of nonlinear loop # --------------------------------------------------------------------------------------------- - + net.converged = False + identify_active_nodes_branches(net, False) + reduce_pit(net, mode="heat_transfer") if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") + vars = ['Tout', 'Tin'] + tol_T = next(get_net_options(net, 'tol_T')) + newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['node', 'branch'], 'max_iter_therm') + if not net.converged: + raise PipeflowNotConverged("The heat transfer calculation did not converge to a " + "solution.") + extract_results_active_pit(net, mode="heat_transfer") - error_t, error_t_out, residual_norm = [], [], None - - net.converged = False - niter = 0 - - # This loop is left as soon as the solver converged - while not net.converged and niter < max_iter: - logger.debug("niter %d" % niter) - - # solve_hydraulics is where the calculation takes place - t_out, t_out_old, t_init, t_init_old, epsilon = solve_temperature(net) - - # Error estimation & convergence plot - delta_t_init = np.abs(t_init - t_init_old) - delta_t_out = np.abs(t_out - t_out_old) - - residual_norm = (linalg.norm(epsilon) / (len(epsilon))) - error_t.append(linalg.norm(delta_t_init) / (len(delta_t_init))) - error_t_out.append(linalg.norm(delta_t_out) / (len(delta_t_out))) - - finalize_iteration(net, niter, error_t, error_t_out, residual_norm, nonlinear_method, tol_t, - tol_t, tol_res, t_init_old, t_out_old, hydraulic_mode=False) - logger.debug("F: %s" % epsilon.round(4)) - logger.debug("T_init_: %s" % t_init.round(4)) - logger.debug("T_out_: %s" % t_out.round(4)) - niter += 1 - - write_internal_results(net, iterations_T=niter, error_T=error_t[niter - 1], - residual_norm_T=residual_norm) - log_final_results(net, niter, residual_norm, hyraulic_mode=False) +def solve_bidirectional(net): + reduce_pit(net, mode="hydraulics") + res_hyd, residual_hyd = solve_hydraulics(net) + extract_results_active_pit(net, mode="hydraulics") + identify_active_nodes_branches(net, False) + reduce_pit(net, mode="heat_transfer") + res_heat, residual_heat = solve_temperature(net) + extract_results_active_pit(net, mode="heat_transfer") + residual = np.concatenate([residual_hyd, residual_heat]) + res = res_hyd + res_heat + return res, residual def solve_hydraulics(net): @@ -217,22 +227,21 @@ def solve_hydraulics(net): branch_lookups = get_lookup(net, "branch", "from_to_active_hydraulics") for comp in net['component_list']: - comp.adaption_before_derivatives_hydraulic( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) calculate_derivatives_hydraulic(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_hydraulic( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) m_init_old = branch_pit[:, MDOTINIT].copy() p_init_old = node_pit[:, PINIT].copy() x = spsolve(jacobian, epsilon) + branch_pit[:, MDOTINIT] -= x[len(node_pit):] node_pit[:, PINIT] -= x[:len(node_pit)] * options["alpha"] - return branch_pit[:, MDOTINIT], node_pit[:, PINIT], m_init_old, p_init_old, epsilon + return [branch_pit[:, MDOTINIT], m_init_old, node_pit[:, PINIT], p_init_old], epsilon def solve_temperature(net): @@ -264,25 +273,24 @@ def solve_temperature(net): branch_pit[mask, TO_NODE_T] = branch_pit[mask, FROM_NODE] for comp in net['component_list']: - comp.adaption_before_derivatives_thermal( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_thermal(net, branch_pit, node_pit, branch_lookups, options) calculate_derivatives_thermal(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_thermal( - net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_thermal(net, branch_pit, node_pit, branch_lookups, options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, True) t_init_old = node_pit[:, TINIT].copy() t_out_old = branch_pit[:, TOUTINIT].copy() x = spsolve(jacobian, epsilon) + node_pit[:, TINIT] += x[:len(node_pit)] * options["alpha"] branch_pit[:, TOUTINIT] += x[len(node_pit):] - return branch_pit[:, TOUTINIT], t_out_old, node_pit[:, TINIT], t_init_old, epsilon + return [branch_pit[:, TOUTINIT], t_out_old, node_pit[:, TINIT], t_init_old], epsilon -def set_damping_factor(net, niter, error): +def set_damping_factor(net, niter, errors): """ Set the value of the damping factor (factor for the newton step width) from current results. @@ -296,67 +304,50 @@ def set_damping_factor(net, niter, error): EXAMPLE: set_damping_factor(net, niter, [error_p, error_v]) """ - error_x0 = error[0] - error_x1 = error[1] - - error_x0_increased = error_x0[niter] > error_x0[niter - 1] - error_x1_increased = error_x1[niter] > error_x1[niter - 1] + error_increased = [] + for error in errors.values(): + error_increased.append(error[niter] > error[niter - 1]) current_alpha = get_net_option(net, "alpha") - - if error_x0_increased and error_x1_increased: + if np.all(error_increased): set_net_option(net, "alpha", current_alpha / 10 if current_alpha >= 0.1 else current_alpha) else: set_net_option(net, "alpha", current_alpha * 10 if current_alpha <= 0.1 else 1.0) - - return error_x0_increased, error_x1_increased + return error_increased -def finalize_iteration(net, niter, error_1, error_2, residual_norm, nonlinear_method, tol_1, tol_2, - tol_res, vals_1_old, vals_2_old, hydraulic_mode=True): - col1, col2 = (PINIT, MDOTINIT) if hydraulic_mode else (TINIT, TOUTINIT) - +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names, + diff): # Control of damping factor if nonlinear_method == "automatic": - error_x0_increased, error_x1_increased = set_damping_factor(net, niter, - [error_1, error_2]) - if error_x0_increased: - net["_active_pit"]["node"][:, col1] = vals_1_old - if error_x1_increased: - net["_active_pit"]["branch"][:, col2] = vals_2_old + errors_increased = set_damping_factor(net, niter, errors) + logger.debug("alpha: %s" % get_net_option(net, "alpha")) + for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): + if error_increased: + net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val + if get_net_option(net, "alpha") != 1: + net.converged = False + return + elif nonlinear_method == "std": + max_std = np.std(list(diff.values()), axis=1)[:5].max() + alpha = 0.33 if max_std == 0 else 1 if max_std < 1 else 0.33 if max_std > 3 else 1 / max_std + set_net_option(net, "alpha", alpha) elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") - - # Setting convergence flag - if error_2[niter] <= tol_2 and error_1[niter] <= tol_1 and residual_norm < tol_res: - if nonlinear_method != "automatic": - net.converged = True - elif get_net_option(net, "alpha") == 1: - net.converged = True - - if hydraulic_mode: - logger.debug("errorv: %s" % error_1[niter]) - logger.debug("errorp: %s" % error_2[niter]) - logger.debug("alpha: %s" % get_net_option(net, "alpha")) - else: - logger.debug("errorT: %s" % error_1[niter]) - logger.debug("alpha: %s" % get_net_option(net, "alpha")) + for error, var, tol in zip(errors.values(), vars, tols): + converged = error[niter] <= tol + if not converged: break + logger.debug("error_%s: %s" % (var, error[niter])) + net.converged = converged and residual_norm <= tol_res -def log_final_results(net, niter, residual_norm, hyraulic_mode=True): - if hyraulic_mode: - solver = "hydraulics" - outputs = ["tol_p", "tol_m"] - else: - solver = "heat transfer" - outputs = ["tol_T"] +def log_final_results(net, solver, niter, residual_norm, vars, tols): logger.debug("--------------------------------------------------------------------------------") if not net.converged: - logger.debug("Maximum number of iterations reached but %s solver did not converge." - % solver) + logger.debug("Maximum number of iterations reached but %s solver did not converge." % solver) logger.debug("Norm of residual: %s" % residual_norm) else: logger.debug("Calculation completed. Preparing results...") logger.debug("Converged after %d iterations." % niter) logger.debug("Norm of residual: %s" % residual_norm) - for out in outputs: - logger.debug("%s: %s" % (out, get_net_option(net, out))) + for var, tol in zip(vars, tols): + logger.debug("tolerance for %s: %s" % (var, tol)) diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py index 51ff4943c..59988e2d7 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_mass.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_mass.py @@ -38,7 +38,7 @@ def test_circulation_pump_constant_mass(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_mass.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py index bb24286f2..925eea905 100644 --- a/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py +++ b/src/pandapipes/test/api/test_components/test_circ_pump_pressure.py @@ -39,7 +39,7 @@ def test_circulation_pump_constant_pressure(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure.csv"), sep=';') diff --git a/src/pandapipes/test/api/test_components/test_ext_grid.py b/src/pandapipes/test/api/test_components/test_ext_grid.py index a78edc713..a334b4fb2 100644 --- a/src/pandapipes/test/api/test_components/test_ext_grid.py +++ b/src/pandapipes/test/api/test_components/test_ext_grid.py @@ -98,7 +98,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -119,7 +119,7 @@ def test_t_type_single_pipe(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -161,7 +161,7 @@ def test_t_type_tee(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -187,7 +187,7 @@ def test_t_type_tee(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values temp_diff = np.abs(1 - temp / temp2) @@ -231,7 +231,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -261,7 +261,7 @@ def test_t_type_tee_2zu_2ab(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -305,7 +305,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -335,7 +335,7 @@ def test_t_type_tee_2zu_2ab2(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values @@ -381,7 +381,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp = net.res_junction.t_k.values @@ -411,7 +411,7 @@ def test_t_type_tee_2zu_2ab3(use_numba): pandapipes.pipeflow(net2, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, mode="all", use_numba=use_numba) + tol_m=1e-4, mode='sequential', use_numba=use_numba) temp2 = net2.res_junction.t_k.values diff --git a/src/pandapipes/test/api/test_components/test_flow_control.py b/src/pandapipes/test/api/test_components/test_flow_control.py index 026532d59..6afc39fdf 100644 --- a/src/pandapipes/test/api/test_components/test_flow_control.py +++ b/src/pandapipes/test/api/test_components/test_flow_control.py @@ -28,7 +28,7 @@ def test_flow_control_simple_heat(use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values, [2, 1]) @@ -37,7 +37,7 @@ def test_flow_control_simple_heat(use_numba): pandapipes.create_flow_control(net, j_new[0], j_new[1], 2, 0.1) pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba, check_connectivity=True) + mode='sequential', use_numba=use_numba, check_connectivity=True) assert np.allclose(net.res_pipe.loc[[p12, p48, p25, p74], "mdot_from_kg_per_s"], [3, 3, 1, 1]) assert np.allclose(net.res_flow_control["mdot_from_kg_per_s"].values[:2], [2, 1]) diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 491a117a5..23e2ce28a 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -6,8 +6,8 @@ import pytest import pandapipes -import pandas as pd import numpy as np +import pytest MDOT = [3, 2] @@ -17,6 +17,7 @@ @pytest.fixture(scope="module") def simple_heat_net(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, system=["flow"] * 3 + ["return"] * 3) pandapipes.create_pipes_from_parameters( @@ -36,12 +37,12 @@ def test_heat_consumer_equivalence(simple_heat_net): controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) - pandapipes.pipeflow(net, mode="all") + pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) - pandapipes.pipeflow(net2, mode="all") + pandapipes.pipeflow(net2, mode='sequential') assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) @@ -53,45 +54,72 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, qext_w=QEXT) - pandapipes.pipeflow(net, mode="all") + pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) pandapipes.create_flow_controls(net2, juncs[[1, 2]], j_mid, MDOT, diameter_m=0.1022) pandapipes.create_heat_exchangers(net2, j_mid, juncs[[4, 3]], 0.1022, QEXT) - pandapipes.pipeflow(net2, mode="all") + pandapipes.pipeflow(net2, mode='sequential') assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) +def test_heat_consumer_equivalence2(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") -def test_heat_consumer_not_implemented_model(simple_heat_net): - net = copy.deepcopy(simple_heat_net) - juncs = net.junction.index + mdot = [3, 3] + qext = [150000, 75000] - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], deltat_k=20) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], - deltat_k=20) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], treturn_k=390) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, qext_w=QEXT[0], - treturn_k=390) - - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - deltat_k=[20, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) - with pytest.raises(NotImplementedError): - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - treturn_k=[390, None]) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, + system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters( + net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, + system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 + ) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + + net2 = copy.deepcopy(net) + net3 = copy.deepcopy(net) + net4 = copy.deepcopy(net) + net5 = copy.deepcopy(net) + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + qext_w=qext[1]) + pandapipes.pipeflow(net, mode="bidirectional") + + pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, + qext_w=qext[1]) + pandapipes.pipeflow(net2, mode="bidirectional", iter=40, nonlinear_method='std') + + pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=5.9673377831196035, + qext_w=qext[1]) + pandapipes.pipeflow(net3, mode="bidirectional") + + pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net4, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + treturn_k= 285.4461399735642) + pandapipes.pipeflow(net4, mode="bidirectional") + + pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], + qext_w=qext[0]) + pandapipes.create_heat_consumer(net5, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], + deltat_k=5.9673377831196035) + pandapipes.pipeflow(net5, mode="bidirectional") + + assert np.allclose(net2.res_junction, net.res_junction) + assert np.allclose(net2.res_pipe, net.res_pipe) + assert np.allclose(net3.res_junction, net.res_junction) + assert np.allclose(net3.res_pipe, net.res_pipe) + assert np.allclose(net4.res_junction, net.res_junction) + assert np.allclose(net4.res_pipe, net.res_pipe) + assert np.allclose(net5.res_junction, net.res_junction) + assert np.allclose(net5.res_pipe, net.res_pipe) def test_heat_consumer_creation_not_allowed(simple_heat_net): diff --git a/src/pandapipes/test/api/test_components/test_heat_exchanger.py b/src/pandapipes/test/api/test_components/test_heat_exchanger.py index d485cf901..fbb27f067 100644 --- a/src/pandapipes/test/api/test_components/test_heat_exchanger.py +++ b/src/pandapipes/test/api/test_components/test_heat_exchanger.py @@ -33,7 +33,7 @@ def test_heat_exchanger(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "heat_exchanger_test.csv"), sep=';', diff --git a/src/pandapipes/test/api/test_time_series.py b/src/pandapipes/test/api/test_time_series.py index b565cbaae..2045ec107 100644 --- a/src/pandapipes/test/api/test_time_series.py +++ b/src/pandapipes/test/api/test_time_series.py @@ -13,9 +13,9 @@ def person_run_fct(net, sol_vec=None, **kwargs): net = ntw.water_strand_net_2pumps() max_iter_hyd = 3 max_iter_therm = 1 - pps.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + pps.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) assert all(np.isclose(net.res_junction.p_bar.values, [7., 25.02309542, 24.73038636, 22.11851835, 16.70728061, 16.23637491])) run_timeseries(net, time_steps=range(10), max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode='all', run=person_run_fct) + mode='sequential', run=person_run_fct) assert all(net.output_writer.iat[0, 0].np_results['res_junction.p_bar'].flatten() == 15.) diff --git a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py index 03c7ab523..74c9f5bf7 100644 --- a/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py +++ b/src/pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py @@ -28,7 +28,7 @@ def test_case_delta(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.05) assert np.all(v_diff_abs < 0.05) @@ -42,7 +42,7 @@ def test_case_delta_2sinks(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -56,7 +56,7 @@ def test_case_heights(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.0065) assert np.all(p_diff < 0.02) assert np.all(v_diff_abs < 0.05) @@ -70,7 +70,7 @@ def test_case_one_pipe(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -84,7 +84,7 @@ def test_case_one_source(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.04) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -98,7 +98,7 @@ def test_case_section_variation(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) # all values of temp_diff_mean are zero except one with about 0.025 assert np.all(temp_diff_mean < 0.03) assert np.all(p_diff < 0.022) @@ -113,7 +113,7 @@ def test_case_t_cross(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.007) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) @@ -127,7 +127,7 @@ def test_case_two_pipes(use_numba, log_results=False): p_diff, v_diff_abs, temp_diff_mean = pipeflow_openmodelica_comparison( net, log_results, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", use_numba=use_numba) + mode='sequential', use_numba=use_numba) assert np.all(temp_diff_mean < 0.004) assert np.all(p_diff < 0.01) assert np.all(v_diff_abs < 0.05) diff --git a/src/pandapipes/test/pipeflow_internals/test_inservice.py b/src/pandapipes/test/pipeflow_internals/test_inservice.py index 29ba322fe..b252ddda1 100644 --- a/src/pandapipes/test/pipeflow_internals/test_inservice.py +++ b/src/pandapipes/test/pipeflow_internals/test_inservice.py @@ -306,7 +306,7 @@ def test_connectivity_heat1(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 3 if use_numba else 3 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) oos_juncs_hyd = {4, 5, 6, 7} oos_pipe_hyd = {5, 7, 8, 9} @@ -346,7 +346,7 @@ def test_connectivity_heat2(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 5 if use_numba else 5 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == {4} assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -379,7 +379,7 @@ def test_connectivity_heat3(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) assert set(net.res_junction.loc[net.res_junction.p_bar.isnull()].index) == set() assert set(net.res_junction.loc[net.res_junction.p_bar.notnull()].index) \ @@ -415,9 +415,9 @@ def test_connectivity_heat4(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 9 if use_numba else 9 max_iter_therm = 6 if use_numba else 6 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=True, use_numba=use_numba) + mode='sequential', check_connectivity=True, use_numba=use_numba) pandapipes.pipeflow(net2, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - mode="all", check_connectivity=False, use_numba=use_numba) + mode='sequential', check_connectivity=False, use_numba=use_numba) assert pandapipes.nets_equal(net, net2, check_only_results=True) @@ -439,11 +439,11 @@ def test_connectivity_heat5(complex_heat_connectivity_grid, use_numba): max_iter_hyd = 9 if use_numba else 9 max_iter_therm = 3 if use_numba else 3 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - check_connectivity=True, mode='all', use_numba=use_numba) + check_connectivity=True, mode='sequential', use_numba=use_numba) with pytest.raises(PipeflowNotConverged): pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, - check_connectivity=False, mode='all', use_numba=use_numba) + check_connectivity=False, mode='sequential', use_numba=use_numba) @pytest.mark.parametrize("use_numba", [True, False]) @@ -669,7 +669,7 @@ def test_pipeflow_all_oos(create_net_wo_ext_grid, use_numba): assert net.converged with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, tol_p=1e-7, tol_m=1e-7, friction_model="nikuradse", use_numba=use_numba, check_connectivity=True) assert ~net.converged diff --git a/src/pandapipes/test/pipeflow_internals/test_options.py b/src/pandapipes/test/pipeflow_internals/test_options.py index 416ac7de2..59b42f7c7 100644 --- a/src/pandapipes/test/pipeflow_internals/test_options.py +++ b/src/pandapipes/test/pipeflow_internals/test_options.py @@ -84,29 +84,29 @@ def test_iter(create_test_net, use_numba): pandapipes.set_user_pf_options(net, iter=2) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.pipeflow(net, mode='hydraulics', max_iter_hyd=max_iter_hyd) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd) + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd) - pandapipes.pipeflow(net, mode='all', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) + pandapipes.pipeflow(net, mode='sequential', max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd) pandapipes.pipeflow(net, mode='hydraulics') with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.set_user_pf_options(net, max_iter_therm=max_iter_therm) - pandapipes.pipeflow(net, mode='all') + pandapipes.pipeflow(net, mode='sequential') pandapipes.set_user_pf_options(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm) with pytest.raises(PipeflowNotConverged): - pandapipes.pipeflow(net, mode='all', iter=2) + pandapipes.pipeflow(net, mode='sequential', iter=2) if __name__ == '__main__': diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index 44d85e71f..389e7c6f8 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -95,7 +95,7 @@ def test_temperature_internal_nodes_single_pipe(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode="all", transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) pipe_results = Pipe.get_internal_results(net, [0]) @@ -150,7 +150,7 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), @@ -193,7 +193,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), @@ -236,7 +236,7 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), @@ -279,7 +279,7 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), sep=';', @@ -324,7 +324,7 @@ def test_temperature_internal_nodes_masche_1load(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_an.csv"), @@ -366,7 +366,7 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='all', transient=False, nonlinear_method="automatic", tol_p=1e-4, + mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, use_numba=use_numba) data = pd.read_csv(os.path.join(data_path, diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py index c982dd8b4..e86e9f30e 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_modes.py @@ -86,7 +86,7 @@ def test_heat_only(use_numba): max_iter_therm = 4 if use_numba else 4 pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, max_iter_therm=max_iter_therm, stop_condition="tol", friction_model="nikuradse", - nonlinear_method="automatic", mode="all", use_numba=use_numba) + nonlinear_method="automatic", mode='sequential', use_numba=use_numba) ntw = pandapipes.create_empty_network("net") d = 75e-3 diff --git a/src/pandapipes/test/test_toolbox.py b/src/pandapipes/test/test_toolbox.py index 9d8193e49..27111a3a1 100644 --- a/src/pandapipes/test/test_toolbox.py +++ b/src/pandapipes/test/test_toolbox.py @@ -264,7 +264,6 @@ def test_select_subnet(base_net_is_wo_pumps): assert len(net2["res_" + comp.table_name()]) == len(net2[comp.table_name()]) assert len(net.junction) == len(net2.junction) + 3 - def test_pit_extraction(): max_ver = max(found_versions) if version.parse(max_ver) >= version.parse(minimal_version_two_nets): diff --git a/tutorials/circular_flow_in_a_district_heating_grid.ipynb b/tutorials/circular_flow_in_a_district_heating_grid.ipynb index a06e23669..07ba52de4 100644 --- a/tutorials/circular_flow_in_a_district_heating_grid.ipynb +++ b/tutorials/circular_flow_in_a_district_heating_grid.ipynb @@ -131,7 +131,7 @@ "metadata": {}, "outputs": [], "source": [ - "pp.pipeflow(net, mode='all')" + "pp.pipeflow(net, mode='sequential')" ] }, { From 70e4a6be18df3abbe1ec510133eda14afc63ca11 Mon Sep 17 00:00:00 2001 From: SRDM Date: Sat, 20 Apr 2024 21:56:08 +0200 Subject: [PATCH 189/237] avoiding one-line if-conditions --- src/pandapipes/pipeflow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 1ef79d2ae..462e7d543 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -78,7 +78,8 @@ def pipeflow(net, sol_vec=None, **kwargs): # determine the active node/branch heat transfer lookup identify_active_nodes_branches(net) - if calculation_mode == 'heat': use_given_hydraulic_results(net, sol_vec) + if calculation_mode == 'heat': + use_given_hydraulic_results(net, sol_vec) if not (calculate_hydraulics | calculate_heat | calculate_bidrect): raise UserWarning("No proper calculation mode chosen.") From e23f0cb53477bf824dd0dae92404c50dbf6cd954 Mon Sep 17 00:00:00 2001 From: SRDM Date: Sun, 21 Apr 2024 00:21:42 +0200 Subject: [PATCH 190/237] std method not working, removed --- src/pandapipes/pipeflow.py | 19 ++++++------------- .../api/test_components/test_heat_consumer.py | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 462e7d543..8b25a98a8 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -111,7 +111,6 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): niter = 0 # This branch is used to stop the solver after a specified error tolerance is reached errors = {var: [] for var in vars} - diff = {var: [] for var in vars} create_internal_results(net) residual_norm = None # This loop is left as soon as the solver converged @@ -128,10 +127,9 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): vals_old = results[pos[1::2]] for var, val_new, val_old in zip(vars, vals_new, vals_old): dval = val_new - val_old - diff[var].append(dval.mean()) errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, - vals_old=vals_old, vars=vars, pit_names=pit_names, diff=diff) + vals_old=vals_old, vars=vars, pit_names=pit_names) niter += 1 write_internal_results(net, **errors) kwargs = dict() @@ -142,8 +140,6 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): def bidirectional(net): - if get_net_option(net, 'nonlinear_method') == 'std': - set_net_option(net, 'alpha', 0.33) net.converged = False if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() @@ -189,9 +185,9 @@ def heat_transfer(net): if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") - vars = ['Tout', 'Tin'] + vars = ['Tout', 'T'] tol_T = next(get_net_options(net, 'tol_T')) - newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['node', 'branch'], 'max_iter_therm') + newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['branch', 'node'], 'max_iter_therm') if not net.converged: raise PipeflowNotConverged("The heat transfer calculation did not converge to a " "solution.") @@ -316,22 +312,19 @@ def set_damping_factor(net, niter, errors): return error_increased -def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names, - diff): +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names): # Control of damping factor if nonlinear_method == "automatic": errors_increased = set_damping_factor(net, niter, errors) logger.debug("alpha: %s" % get_net_option(net, "alpha")) for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): if error_increased: + # todo: not working in bidirectional mode as bidirectional is not distinguishing between \ + # hydraulics and heat transfer active pit net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val if get_net_option(net, "alpha") != 1: net.converged = False return - elif nonlinear_method == "std": - max_std = np.std(list(diff.values()), axis=1)[:5].max() - alpha = 0.33 if max_std == 0 else 1 if max_std < 1 else 0.33 if max_std > 3 else 1 / max_std - set_net_option(net, "alpha", alpha) elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") for error, var, tol in zip(errors.values(), vars, tols): diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 23e2ce28a..ec0342ae4 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -92,7 +92,7 @@ def test_heat_consumer_equivalence2(): qext_w=qext[0]) pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, qext_w=qext[1]) - pandapipes.pipeflow(net2, mode="bidirectional", iter=40, nonlinear_method='std') + pandapipes.pipeflow(net2, mode="bidirectional", iter=20, alpha=0.65) pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) From 4e15285911e7be63765e532918d522fbd9d080ee Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 7 May 2024 06:55:29 +0200 Subject: [PATCH 191/237] fix failing tests due to hard coded pandapower geojson implementation not converted to pandapipes --- .../valve_pipe_plotting.py | 8 +-- src/pandapipes/create.py | 24 +++++++-- src/pandapipes/plotting/collections.py | 8 +-- src/pandapipes/plotting/plotting_toolbox.py | 52 ++++++++++++++++++- 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py index 16592eda6..1711413d9 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_plotting.py @@ -6,11 +6,11 @@ import numpy as np import pandas as pd -from pandapower.plotting.collections import _create_complex_branch_collection, \ - add_cmap_to_collection, coords_from_node_geodata -from pandapower.plotting.plotting_toolbox import get_index_array - from pandapipes.plotting.patch_makers import valve_patches +from pandapipes.plotting.plotting_toolbox import coords_from_node_geodata +from pandapower.plotting.collections import (_create_complex_branch_collection, + add_cmap_to_collection) +from pandapower.plotting.plotting_toolbox import get_index_array try: import pandaplan.core.pplog as logging diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 55c8ac8ef..641c98007 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,9 +4,10 @@ import numpy as np import pandas as pd -from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, _check_node_element, \ - _check_multiple_node_elements, _set_multiple_entries, _add_multiple_branch_geodata, _check_branch_element, \ - _check_multiple_branch_elements +from pandapower.auxiliary import _preserve_dtypes +from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ + _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ + _check_branch_element, _check_multiple_branch_elements from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, HeatExchanger, Valve, \ CirculationPumpPressure, CirculationPumpMass, PressureControlComponent, Compressor, MassStorage @@ -1776,6 +1777,23 @@ def _check_std_type(net, std_type, table, function_name): 'one' % (std_type, table)) +def _add_multiple_branch_geodata(net, table, geodata, index): + geo_table = f"{table}_geodata" + dtypes = net[geo_table].dtypes + df = pd.DataFrame(index=index, columns=net[geo_table].columns) + # works with single or multiple lists of coordinates + if len(geodata[0]) == 2 and not hasattr(geodata[0][0], "__iter__"): + # geodata is a single list of coordinates + df["coords"] = [geodata] * len(index) + else: + # geodata is multiple lists of coordinates + df["coords"] = geodata + + net[geo_table] = pd.concat([net[geo_table],df], sort=False) + + _preserve_dtypes(net[geo_table], dtypes) + + ALLOWED_EG_TYPES = ["auto", "t", "p", "pt", "tp"] diff --git a/src/pandapipes/plotting/collections.py b/src/pandapipes/plotting/collections.py index 144b64d63..d7c5c96a1 100644 --- a/src/pandapipes/plotting/collections.py +++ b/src/pandapipes/plotting/collections.py @@ -4,12 +4,12 @@ import numpy as np import pandas as pd -from pandapower.plotting.collections import _create_node_collection, \ - _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection, \ - add_cmap_to_collection, coords_from_node_geodata -from pandapower.plotting.patch_makers import load_patches, ext_grid_patches from pandapipes.plotting.patch_makers import valve_patches, source_patches, heat_exchanger_patches, \ pump_patches, pressure_control_patches, compressor_patches, flow_control_patches +from pandapipes.plotting.plotting_toolbox import coords_from_node_geodata +from pandapower.plotting.collections import _create_node_collection, add_cmap_to_collection, \ + _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection +from pandapower.plotting.patch_makers import load_patches, ext_grid_patches from pandapower.plotting.plotting_toolbox import get_index_array try: diff --git a/src/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py index 23b5817ec..226725cc1 100644 --- a/src/pandapipes/plotting/plotting_toolbox.py +++ b/src/pandapipes/plotting/plotting_toolbox.py @@ -2,6 +2,15 @@ # 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 +try: + import pandaplan.core.pplog as logging +except ImportError: + import logging + +logger = logging.getLogger(__name__) + + def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1.0, source_size=1.0, valve_size=2.0, pump_size=1.0, heat_exchanger_size=1.0, pressure_control_size=1.0, compressor_size=1.0, flow_control_size=1.0): @@ -10,7 +19,7 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. geocoord so that the collections fit the plot nicely .. note: This is implemented because if you would choose a fixed values (e.g.\ - junction_size = 0.2), the size could be to small for large networks and vice versa + junction_size = 0.2), the size could be too small for large networks and vice versa :param net: pandapower network for which to create plot :type net: pandapowerNet @@ -46,3 +55,44 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. return sizes + +def coords_from_node_geodata(element_indices, from_nodes, to_nodes, node_geodata, table_name, + node_name="Bus", ignore_zero_length=True): + """ + Auxiliary function to get the node coordinates for a number of branches with respective from + and to nodes. The branch elements for which there is no geodata available are not included in + the final list of coordinates. + + :param element_indices: Indices of the branch elements for which to find node geodata + :type element_indices: iterable + :param from_nodes: Indices of the starting nodes + :type from_nodes: iterable + :param to_nodes: Indices of the ending nodes + :type to_nodes: iterable + :param node_geodata: Dataframe containing x and y coordinates of the nodes + :type node_geodata: pd.DataFrame + :param table_name: Name of the table that the branches belong to (only for logging) + :type table_name: str + :param node_name: Name of the node type (only for logging) + :type node_name: str, default "Bus" + :param ignore_zero_length: States if branches should be left out, if their length is zero, i.e.\ + from_node_coords = to_node_coords + :type ignore_zero_length: bool, default True + :return: Return values are:\ + - coords (list) - list of branch coordinates of shape (N, (2, 2))\ + - elements_with_geo (set) - the indices of branch elements for which coordinates wer found\ + in the node geodata table + """ + have_geo = np.isin(from_nodes, node_geodata.index.values) \ + & np.isin(to_nodes, node_geodata.index.values) + elements_with_geo = np.array(element_indices)[have_geo] + fb_with_geo, tb_with_geo = from_nodes[have_geo], to_nodes[have_geo] + coords = [[(x_from, y_from), (x_to, y_to)] for x_from, y_from, x_to, y_to + in np.concatenate([node_geodata.loc[fb_with_geo, ["x", "y"]].values, + node_geodata.loc[tb_with_geo, ["x", "y"]].values], axis=1) + if not ignore_zero_length or not (x_from == x_to and y_from == y_to)] + elements_without_geo = set(element_indices) - set(elements_with_geo) + if len(elements_without_geo) > 0: + logger.warning("No coords found for %s %s. %s geodata is missing for those %s!" + % (table_name + "s", elements_without_geo, node_name, table_name + "s")) + return coords, elements_with_geo From d1a747276dc90992ebcbbc7fd9902423759a96bb Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Wed, 17 Apr 2024 11:51:55 +0200 Subject: [PATCH 192/237] - circulation pumps are considered as default slack nodes as well - unsupplied junctions will not be plottet --- src/pandapipes/plotting/pipeflow_results.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index c3810043b..bc32fc810 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -7,6 +7,7 @@ import pandas as pd import matplotlib.pyplot as plt import numpy as np +from warnings import warn def pressure_profile_to_junction_geodata(net): @@ -89,10 +90,21 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control if pipes is None: pipes = net.pipe.index if x0_junctions is None: - x0_junctions = net.ext_grid[net.ext_grid.in_service].junction.values.tolist() + x0_junctions = set(net.ext_grid[net.ext_grid.in_service].junction.values) + if hasattr(net, "circ_pump_pressure"): + x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].junction.values) + if hasattr(net, "circ_pump_mass"): + x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].junction.values) + x0_junctions = list(x0_junctions) + + unsupplied_junctions = list(top.unsupplied_junctions(net, slacks=set(x0_junctions))) + if len(unsupplied_junctions) > 0: + warn(UserWarning(f'There are unsupplied junctions in the net, they will not be plottet: {unsupplied_junctions}')) + pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes) & + ~net.pipe.from_junction.isin(unsupplied_junctions) & + ~net.pipe.to_junction.isin(unsupplied_junctions)] d = top.calc_distance_to_junctions(net, x0_junctions) - pipe_table = net.pipe[net.pipe.in_service & net.pipe.index.isin(pipes)] x = np.array([d.loc[pipe_table.from_junction].values, d.loc[pipe_table.to_junction].values]) + x0 y = np.array([net.res_junction.p_bar.loc[pipe_table.from_junction].values, net.res_junction.p_bar.loc[pipe_table.to_junction].values]) From 8f49e8de76e63aefdf290f9189295cedf23f271a Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 13 May 2024 08:33:13 +0200 Subject: [PATCH 193/237] some pep --- src/pandapipes/pipeflow.py | 88 +++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index 8b25a98a8..a2f9d0fe8 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -6,13 +6,18 @@ from numpy import linalg from scipy.sparse.linalg import spsolve -from pandapipes.idx_branch import FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, MDOTINIT_T +from pandapipes.idx_branch import (FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, + MDOTINIT_T) from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix -from pandapipes.pf.derivative_calculation import calculate_derivatives_hydraulic, calculate_derivatives_thermal -from pandapipes.pf.pipeflow_setup import get_net_option, get_net_options, set_net_option, init_options, \ - create_internal_results, write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, \ - set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, PipeflowNotConverged +from pandapipes.pf.derivative_calculation import (calculate_derivatives_hydraulic, + calculate_derivatives_thermal) +from pandapipes.pf.pipeflow_setup import ( + get_net_option, get_net_options, set_net_option, init_options, create_internal_results, + write_internal_results, get_lookup, create_lookups, initialize_pit, reduce_pit, + set_user_pf_options, init_all_result_tables, identify_active_nodes_branches, + PipeflowNotConverged +) from pandapipes.pf.result_extraction import extract_all_results, extract_results_active_pit try: @@ -74,8 +79,8 @@ def pipeflow(net, sol_vec=None, **kwargs): calculate_heat = calculation_mode in ["heat", 'sequential'] calculate_bidrect = calculation_mode == "bidirectional" - # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also required to - # determine the active node/branch heat transfer lookup + # cannot be moved to calculate_hydraulics as the active node/branch hydraulics lookup is also + # required to determine the active node/branch heat transfer lookup identify_active_nodes_branches(net) if calculation_mode == 'heat': @@ -106,11 +111,13 @@ def use_given_hydraulic_results(net, sol_vec): branch_pit[:, MDOTINIT] = sol_vec[len(node_pit):] -def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): - max_iter, nonlinear_method, tol_res = get_net_options(net, iter_name, "nonlinear_method", "tol_res") +def newton_raphson(net, funct, mode, solver_vars, tols, pit_names, iter_name): + max_iter, nonlinear_method, tol_res = get_net_options( + net, iter_name, "nonlinear_method", "tol_res" + ) niter = 0 # This branch is used to stop the solver after a specified error tolerance is reached - errors = {var: [] for var in vars} + errors = {var: [] for var in solver_vars} create_internal_results(net) residual_norm = None # This loop is left as soon as the solver converged @@ -121,32 +128,36 @@ def newton_raphson(net, funct, mode, vars, tols, pit_names, iter_name): results, residual = funct(net) residual_norm = linalg.norm(residual / len(residual)) logger.debug("residual: %s" % residual_norm.round(4)) - pos = np.arange(len(vars) * 2) + pos = np.arange(len(solver_vars) * 2) results = np.array(results, object) vals_new = results[pos[::2]] vals_old = results[pos[1::2]] - for var, val_new, val_old in zip(vars, vals_new, vals_old): + for var, val_new, val_old in zip(solver_vars, vals_new, vals_old): dval = val_new - val_old errors[var].append(linalg.norm(dval) / len(dval) if len(dval) else 0) - finalize_iteration(net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, - vals_old=vals_old, vars=vars, pit_names=pit_names) + finalize_iteration( + net, niter, residual_norm, nonlinear_method, errors=errors, tols=tols, tol_res=tol_res, + vals_old=vals_old, solver_vars=solver_vars, pit_names=pit_names + ) niter += 1 write_internal_results(net, **errors) kwargs = dict() kwargs['residual_norm_%s' % mode] = residual_norm kwargs['iterations_%s' % mode] = niter write_internal_results(net, **kwargs) - log_final_results(net, mode, niter, residual_norm, vars, tols) + log_final_results(net, mode, niter, residual_norm, solver_vars, tols) def bidirectional(net): net.converged = False if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() - vars = ['mdot', 'p', 'TOUT', 'T'] + solver_vars = ['mdot', 'p', 'TOUT', 'T'] tol_m, tol_p, tol_T = get_net_options(net, 'tol_m', 'tol_p', 'tol_T') - newton_raphson(net, solve_bidirectional, 'bidirectional', vars, [tol_m, tol_p, tol_T, tol_T], - ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect') + newton_raphson( + net, solve_bidirectional, 'bidirectional', solver_vars, [tol_m, tol_p, tol_T, tol_T], + ['branch', 'node', 'branch', 'node'], 'max_iter_bidirect' + ) if net.converged: set_user_pf_options(net, hyd_flag=True) if not get_net_option(net, "reuse_internal_data"): @@ -162,9 +173,10 @@ def hydraulics(net): reduce_pit(net, mode="hydraulics") if not get_net_option(net, "reuse_internal_data") or "_internal_data" not in net: net["_internal_data"] = dict() - vars = ['mdot', 'p'] + solver_vars = ['mdot', 'p'] tol_p, tol_m = get_net_options(net, 'tol_m', 'tol_p') - newton_raphson(net, solve_hydraulics, 'hydraulics', vars, [tol_m, tol_p], ['branch', 'node'], 'max_iter_hyd') + newton_raphson(net, solve_hydraulics, 'hydraulics', solver_vars, [tol_m, tol_p], + ['branch', 'node'], 'max_iter_hyd') if net.converged: set_user_pf_options(net, hyd_flag=True) @@ -185,9 +197,10 @@ def heat_transfer(net): if net.fluid.is_gas: logger.info("Caution! Temperature calculation does currently not affect hydraulic " "properties!") - vars = ['Tout', 'T'] + solver_vars = ['Tout', 'T'] tol_T = next(get_net_options(net, 'tol_T')) - newton_raphson(net, solve_temperature, 'heat', vars, [tol_T, tol_T], ['branch', 'node'], 'max_iter_therm') + newton_raphson(net, solve_temperature, 'heat', solver_vars, [tol_T, tol_T], ['branch', 'node'], + 'max_iter_therm') if not net.converged: raise PipeflowNotConverged("The heat transfer calculation did not converge to a " "solution.") @@ -224,10 +237,12 @@ def solve_hydraulics(net): branch_lookups = get_lookup(net, "branch", "from_to_active_hydraulics") for comp in net['component_list']: - comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_before_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, + options) calculate_derivatives_hydraulic(net, branch_pit, node_pit, options) for comp in net['component_list']: - comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, options) + comp.adaption_after_derivatives_hydraulic(net, branch_pit, node_pit, branch_lookups, + options) jacobian, epsilon = build_system_matrix(net, branch_pit, node_pit, False) m_init_old = branch_pit[:, MDOTINIT].copy() @@ -295,7 +310,7 @@ def set_damping_factor(net, niter, errors): :type net: pandapipesNet :param niter: :type niter: - :param error: an array containing the current residuals of all field variables solved for + :param errors: an array containing the current residuals of all field variables solved for :return: No Output. EXAMPLE: @@ -312,36 +327,39 @@ def set_damping_factor(net, niter, errors): return error_increased -def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, vars, pit_names): +def finalize_iteration(net, niter, residual_norm, nonlinear_method, errors, tols, tol_res, vals_old, + solver_vars, pit_names): # Control of damping factor if nonlinear_method == "automatic": errors_increased = set_damping_factor(net, niter, errors) logger.debug("alpha: %s" % get_net_option(net, "alpha")) - for error_increased, var, val, pit in zip(errors_increased, vars, vals_old, pit_names): + for error_increased, var, val, pit in zip(errors_increased, solver_vars, vals_old, + pit_names): if error_increased: - # todo: not working in bidirectional mode as bidirectional is not distinguishing between \ - # hydraulics and heat transfer active pit + # todo: not working in bidirectional mode as bidirectional is not distinguishing \ + # between hydraulics and heat transfer active pit net["_active_pit"][pit][:, globals()[var.upper() + 'INIT']] = val if get_net_option(net, "alpha") != 1: net.converged = False return elif nonlinear_method != "constant": logger.warning("No proper nonlinear method chosen. Using constant settings.") - for error, var, tol in zip(errors.values(), vars, tols): - converged = error[niter] <= tol - if not converged: break + converged = True + for error, var, tol in zip(errors.values(), solver_vars, tols): + converged = converged and error[niter] <= tol logger.debug("error_%s: %s" % (var, error[niter])) net.converged = converged and residual_norm <= tol_res -def log_final_results(net, solver, niter, residual_norm, vars, tols): +def log_final_results(net, solver, niter, residual_norm, solver_vars, tols): logger.debug("--------------------------------------------------------------------------------") if not net.converged: - logger.debug("Maximum number of iterations reached but %s solver did not converge." % solver) + logger.debug( + "Maximum number of iterations reached but %s solver did not converge." % solver) logger.debug("Norm of residual: %s" % residual_norm) else: logger.debug("Calculation completed. Preparing results...") logger.debug("Converged after %d iterations." % niter) logger.debug("Norm of residual: %s" % residual_norm) - for var, tol in zip(vars, tols): + for var, tol in zip(solver_vars, tols): logger.debug("tolerance for %s: %s" % (var, tol)) From 36dd4924fe1eacf72fda5e4352c7be53c0a9f51b Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 13 May 2024 08:40:12 +0200 Subject: [PATCH 194/237] some more pep --- .../heat_consumer_component.py | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 064c63d0c..f7405ac31 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -5,11 +5,13 @@ import numpy as np from numpy import dtype -from pandapipes.component_models import get_fluid, BranchWZeroLengthComponent, get_component_array, \ - standard_branch_wo_internals_result_lookup +from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array, + standard_branch_wo_internals_result_lookup) from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, \ +from pandapipes.idx_branch import ( + D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE +) from pandapipes.idx_node import TINIT from pandapipes.pf.result_extraction import extract_branch_results_without_internals from pandapipes.properties.properties_toolbox import get_branch_cp @@ -61,7 +63,6 @@ def create_pit_branch_entries(cls, net, branch_pit): :type branch_pit: :return: No Output. """ - node_pit = net['_pit']['node'] hc_pit = super().create_pit_branch_entries(net, branch_pit) hc_pit[:, D] = net[cls.table_name()].diameter_m.values hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 @@ -153,7 +154,8 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo node_pit[from_nodes[t_mask], TINIT] += 10 t_in = node_pit[from_nodes, TINIT] df_dm = - cp[mask] * (t_out - t_in) - hc_pit[mask, LOAD_VEC_BRANCHES] = - consumer_array[mask, cls.QEXT] + df_dm * hc_pit[mask, MDOTINIT] + hc_pit[mask, LOAD_VEC_BRANCHES] = (- consumer_array[mask, cls.QEXT] + df_dm + * hc_pit[mask, MDOTINIT]) hc_pit[mask, JAC_DERIV_DM] = df_dm @classmethod @@ -199,9 +201,10 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), - ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), - ("in_service", "bool"), ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), + ("qext_w", "f8"), ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), + ("treturn_k", "f8"), ("diameter_m", "f8"), ("in_service", "bool"), + ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -216,12 +219,14 @@ def get_result_table(cls, net): :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"] + 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"] + 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 @classmethod @@ -241,5 +246,6 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, - cls.table_name(), mode) + extract_branch_results_without_internals( + net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode + ) From 87878e61efcc3476a1403470b0e6219d97bb597a Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:02:35 +0200 Subject: [PATCH 195/237] setting text of pipes to None and assuming ambient temperature --- src/pandapipes/create.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 641c98007..53fea55c2 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -374,7 +374,7 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, - alpha_w_per_m2k=0., qext_w=0., text_k=None, name=None, index=None, geodata=None, in_service=True, + alpha_w_per_m2k=0., text_k=None, qext_w=0.,name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -399,10 +399,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 - :param qext_w: External heat feed-in to the pipe in [W] - :type qext_w: float, default 0 :param text_k: Ambient temperature of pipe in [K] :type text_k: float, default None, will be set equal to the net ambient temperature + :param qext_w: External heat feed-in to the pipe in [W] + :type qext_w: float, default 0 :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -446,7 +446,7 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + sections=1, alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Creates a pipe element in net["pipe"] from pipe parameters. @@ -471,10 +471,10 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam :type sections: int, default 1 :param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)] :type alpha_w_per_m2k: float, default 0 + :param text_k: Ambient temperature of pipe in [K] + :type text_k: float, default None, will be set equal to the net ambient temperature :param qext_w: external heat feed-in to the pipe in [W] :type qext_w: float, default 0 - :param text_k: Ambient temperature of pipe in [K] - :type text_k: float, default 293 :param name: A name tag for this pipe :type name: str, default None :param index: Force a specified ID if it is available. If None, the index one higher than the\ @@ -1265,7 +1265,7 @@ def create_ext_grids(net, junctions, p_bar, t_k, name=None, in_service=True, ind def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0.2, loss_coefficient=0, sections=1, - alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None, in_service=True, + alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ @@ -1295,7 +1295,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] :type alpha_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] - :type text_k: Iterable or float, default 293 + :type text_k: Iterable or float, default None, will be set equal to the net ambient temperature :param qext_w: External heat feed-in to the pipes in [W] :type qext_w: Iterable or float, default 0 :param name: Name tags for these pipes @@ -1344,7 +1344,7 @@ def create_pipes(net, from_junctions, to_junctions, std_type, length_km, k_mm=0. def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, diameter_m, k_mm=0.2, loss_coefficient=0, - sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, + sections=1, alpha_w_per_m2k=0., text_k=None, qext_w=0., name=None, index=None, geodata=None, in_service=True, type="pipe", **kwargs): """ Convenience function for creating many pipes at once. Parameters 'from_junctions' and \ @@ -1373,7 +1373,7 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d :param alpha_w_per_m2k: Heat transfer coefficients in [W/(m^2*K)] :type alpha_w_per_m2k: Iterable or float, default 0 :param text_k: Ambient temperatures of pipes in [K] - :type text_k: Iterable or float, default 293 + :type text_k: Iterable or float, default None, will be set equal to the net ambient temperature :param qext_w: External heat feed-in to the pipes in [W] :type qext_w: Iterable or float, default 0 :param name: Name tags for these pipes From c97fd2a658e51364dfd15350d740fc833154b583 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:03:00 +0200 Subject: [PATCH 196/237] adapting the heat consumer tests --- .../api/test_components/test_heat_consumer.py | 127 +++++++++--------- 1 file changed, 61 insertions(+), 66 deletions(-) diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index ec0342ae4..029a52123 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -3,12 +3,10 @@ # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. import copy -import pytest - -import pandapipes import numpy as np import pytest +import pandapipes MDOT = [3, 2] QEXT = [150000, 75000] @@ -18,12 +16,10 @@ def simple_heat_net(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") - juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, - system=["flow"] * 3 + ["return"] * 3) - pandapipes.create_pipes_from_parameters( - net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, - system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 - ) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=283.15, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 400, type='pt') return net @@ -33,10 +29,8 @@ def test_heat_consumer_equivalence(simple_heat_net): net2 = copy.deepcopy(simple_heat_net) juncs = net.junction.index - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) - pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, - controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=MDOT[1], qext_w=QEXT[1]) pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) @@ -52,8 +46,8 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): net2 = copy.deepcopy(simple_heat_net) juncs = net.junction.index - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, qext_w=QEXT) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, + qext_w=QEXT) pandapipes.pipeflow(net, mode='sequential') j_mid = pandapipes.create_junctions(net2, 2, pn_bar=5, tfluid_k=283.15) @@ -63,18 +57,17 @@ def test_heat_consumer_equivalence_bulk(simple_heat_net): assert np.allclose(net.res_junction.values, net2.res_junction.iloc[:-2, :].values) + def test_heat_consumer_equivalence2(): net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") - mdot = [3, 3] + mdot = [1, 1] qext = [150000, 75000] - juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, - system=["flow"] * 3 + ["return"] * 3) - pandapipes.create_pipes_from_parameters( - net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, diameter_m=0.1022, - system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, text_k=273.15 - ) + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') net2 = copy.deepcopy(net) @@ -82,34 +75,26 @@ def test_heat_consumer_equivalence2(): net4 = copy.deepcopy(net) net5 = copy.deepcopy(net) - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - qext_w=qext[1]) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], qext_w=qext[1]) pandapipes.pipeflow(net, mode="bidirectional") - pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k= 285.4461399735642, - qext_w=qext[1]) - pandapipes.pipeflow(net2, mode="bidirectional", iter=20, alpha=0.65) + pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k=263.4459264973806, qext_w=qext[1]) + pandapipes.pipeflow(net2, mode="bidirectional", iter=25, alpha=0.5) - pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) - pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=5.9673377831196035, - qext_w=qext[1]) + pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) + pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=17.82611044059695, qext_w=qext[1]) pandapipes.pipeflow(net3, mode="bidirectional") - pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) + pandapipes.create_heat_consumer(net4, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net4, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - treturn_k= 285.4461399735642) + treturn_k=263.4459264973806) pandapipes.pipeflow(net4, mode="bidirectional") - pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], - qext_w=qext[0]) + pandapipes.create_heat_consumer(net5, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net5, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=mdot[1], - deltat_k=5.9673377831196035) + deltat_k=17.82611044059695) pandapipes.pipeflow(net5, mode="bidirectional") assert np.allclose(net2.res_junction, net.res_junction) @@ -128,13 +113,12 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): with pytest.raises(AttributeError): # check for less than 2 set parameters - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=None, + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], qext_w=None, treturn_k=None) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, qext_w=[QEXT[0], None]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, + qext_w=[QEXT[0], None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, @@ -145,52 +129,63 @@ def test_heat_consumer_creation_not_allowed(simple_heat_net): controlled_mdot_kg_per_s=None) -@pytest.mark.xfail(reason="Can only be tested once models for deltat_k and treturn_k" - " are implemented for heat consumers.") def test_heat_consumer_creation_not_allowed_2(simple_heat_net): net = copy.deepcopy(simple_heat_net) juncs = net.junction.index with pytest.raises(AttributeError): # check for more than 2 set parameters - pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, - controlled_mdot_kg_per_s=MDOT[0], qext_w=QEXT[0], - treturn_k=390) + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=MDOT[0], + qext_w=QEXT[0], treturn_k=390) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, deltat_k=20, treturn_k=390) with pytest.raises(AttributeError): # check for more than 2 set parameters - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=[30, 40], treturn_k=[390, 385]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=[30, 40], + treturn_k=[390, 385]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) - with pytest.raises(AttributeError): - # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, deltat_k=[20, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, deltat_k=[20, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in some consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, controlled_mdot_kg_per_s=MDOT, treturn_k=[390, None]) + with pytest.raises(AttributeError): + # check for less than 2 set parameters in some consumers + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=[390, None]) with pytest.raises(AttributeError): # check for less than 2 set parameters in all consumers - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, - treturn_k=None, controlled_mdot_kg_per_s=None) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, qext_w=QEXT, treturn_k=None, + controlled_mdot_kg_per_s=None) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=[30, 40], treturn_k=[390, 385]) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=[30, 40], + treturn_k=[390, 385]) with pytest.raises(AttributeError): # check for deltat_k and treturn_k given as single values - pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, - deltat_k=30, treturn_k=390) + pandapipes.create_heat_consumers(net, juncs[[1, 2]], juncs[[4, 3]], 0.1022, deltat_k=30, treturn_k=390) + + +def test_heat_consumer_qext_zero(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, treturn_k=263.4459264973806, qext_w=0) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=1, qext_w=7500) + + pandapipes.pipeflow(net, mode="bidirectional", iter=25, alpha=0.5) + + assert net.res_junction.at[juncs[4], 't_k'] != 263.4459264973806 if __name__ == '__main__': From 4cd74e184055a81b6f50e45588ef7974892ce3d4 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:03:38 +0200 Subject: [PATCH 197/237] from node t and to node t are no fix entries and can be passed from active to general pit --- src/pandapipes/pf/result_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 0dfaa2c7a..6a4b616a0 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -286,7 +286,7 @@ def extract_results_active_pit(net, mode="hydraulics"): result_branch_col = MDOTINIT if mode == "hydraulics" else TOUTINIT not_affected_branch_col = TOUTINIT if mode == "hydraulics" else MDOTINIT copied_branch_cols = np.array([i for i in range(net["_pit"]["branch"].shape[1]) - if i not in [FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, + if i not in [FROM_NODE, TO_NODE, not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] From 843183a38326e3e2bbddb798eba0c153ef43e232 Mon Sep 17 00:00:00 2001 From: SRDM Date: Tue, 4 Jun 2024 10:04:15 +0200 Subject: [PATCH 198/237] further adaption of heat consumer component --- .../heat_consumer_component.py | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index f7405ac31..367caf239 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -8,11 +8,10 @@ from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup) from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import ( - D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, - LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE -) +from pandapipes.idx_branch import (D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, + LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T) from pandapipes.idx_node import TINIT +from pandapipes.pf.pipeflow_setup import get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals from pandapipes.properties.properties_toolbox import get_branch_cp @@ -66,11 +65,12 @@ def create_pit_branch_entries(cls, net, branch_pit): hc_pit = super().create_pit_branch_entries(net, branch_pit) hc_pit[:, D] = net[cls.table_name()].diameter_m.values hc_pit[:, AREA] = hc_pit[:, D] ** 2 * np.pi / 4 - hc_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values - hc_pit[:, QEXT] = net[cls.table_name()].qext_w.values - # causes otherwise problems in case of mode Q - hc_pit[np.isnan(hc_pit[:, MDOTINIT]), MDOTINIT] = 0.1 - hc_pit[hc_pit[:, QEXT] == 0, ACTIVE] = False + qext = net[cls.table_name()].qext_w.values + hc_pit[~np.isnan(qext), QEXT] = qext[~np.isnan(qext)] + mdot = net[cls.table_name()].controlled_mdot_kg_per_s.values + hc_pit[~np.isnan(mdot), MDOTINIT] = mdot[~np.isnan(mdot)] + treturn = net[cls.table_name()].treturn_k.values + hc_pit[~np.isnan(treturn), TOUTINIT] = treturn[~np.isnan(treturn)] return hc_pit @classmethod @@ -88,14 +88,15 @@ def create_component_array(cls, net, component_pits): """ tbl = net[cls.table_name()] consumer_array = np.zeros(shape=(len(tbl), cls.internal_cols), dtype=np.float64) - consumer_array[:, cls.MASS] = tbl.controlled_mdot_kg_per_s.values - consumer_array[:, cls.QEXT] = tbl.qext_w.values consumer_array[:, cls.DELTAT] = tbl.deltat_k.values - consumer_array[:, cls.TRETURN] = tbl.treturn_k.values - mf = ~np.isnan(consumer_array[:, cls.MASS]) - qe = ~np.isnan(consumer_array[:, cls.QEXT]) - dt = ~np.isnan(consumer_array[:, cls.DELTAT]) - tr = ~np.isnan(consumer_array[:, cls.TRETURN]) + mf = tbl.controlled_mdot_kg_per_s.values + tr = tbl.treturn_k.values + dt = tbl.deltat_k.values + qe = tbl.qext_w.values + mf = ~np.isnan(mf) + tr = ~np.isnan(tr) + dt = ~np.isnan(dt) + qe = ~np.isnan(qe) consumer_array[mf & dt, cls.MODE] = cls.MF_DT consumer_array[mf & tr, cls.MODE] = cls.MF_TR consumer_array[qe & mf, cls.MODE] = cls.QE_MF @@ -112,8 +113,8 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo mask = consumer_array[:, cls.MODE] == cls.QE_DT if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - deltat = net[cls.table_name()].deltat_k.values - mass = consumer_array[mask, cls.QEXT] / (cp[mask] * (deltat[mask])) + deltat = consumer_array[:, cls.DELTAT] + mass = hc_pit[mask, QEXT] / (cp[mask] * (deltat[mask])) hc_pit[mask, MDOTINIT] = mass @classmethod @@ -148,15 +149,15 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo mask = consumer_array[:, cls.MODE] == cls.QE_TR if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) - t_out = consumer_array[mask, cls.TRETURN] - t_mask = hc_pit[mask, TOUTINIT] == node_pit[from_nodes, TINIT] - node_pit[from_nodes[t_mask], TINIT] += 10 + from_nodes = hc_pit[:, FROM_NODE_T].astype(int) t_in = node_pit[from_nodes, TINIT] - df_dm = - cp[mask] * (t_out - t_in) - hc_pit[mask, LOAD_VEC_BRANCHES] = (- consumer_array[mask, cls.QEXT] + df_dm - * hc_pit[mask, MDOTINIT]) - hc_pit[mask, JAC_DERIV_DM] = df_dm + t_out = hc_pit[:, TOUTINIT] + + df_dm = - cp * (t_out - t_in) + hc_pit[mask, LOAD_VEC_BRANCHES] = - hc_pit[mask, QEXT] + df_dm[mask] * hc_pit[mask, MDOTINIT] + mask_equal = t_out == t_in + hc_pit[mask & mask_equal, MDOTINIT] = 0 + hc_pit[mask & ~mask_equal, JAC_DERIV_DM] = df_dm[mask & ~mask_equal] @classmethod def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options): @@ -166,7 +167,7 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look mask = consumer_array[:, cls.MODE] == cls.MF_DT if np.any(mask): cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - q_ext = cp[mask] * consumer_array[mask, cls.MASS] * consumer_array[mask, cls.DELTAT] + q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * consumer_array[mask, cls.DELTAT] hc_pit[mask, QEXT] = q_ext mask = consumer_array[:, cls.MODE] == cls.MF_TR @@ -175,7 +176,7 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) t_in = node_pit[from_nodes, TINIT] t_out = hc_pit[mask, TOUTINIT] - q_ext = cp[mask] * consumer_array[mask, cls.MASS] * (t_in - t_out) + q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * (t_in - t_out) hc_pit[mask, QEXT] = q_ext @classmethod @@ -188,9 +189,8 @@ def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_looku mask = np.isin(consumer_array[:, cls.MODE], [cls.MF_TR, cls.QE_TR]) if np.any(mask): hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0 - hc_pit[mask, JAC_DERIV_DTOUT] = -1 + hc_pit[mask, JAC_DERIV_DTOUT] = 1 hc_pit[mask, JAC_DERIV_DT] = 0 - hc_pit[mask, TOUTINIT] = consumer_array[mask, cls.TRETURN] @classmethod def get_component_input(cls): @@ -201,10 +201,9 @@ def get_component_input(cls): :return: :rtype: """ - return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), - ("qext_w", "f8"), ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), - ("treturn_k", "f8"), ("diameter_m", "f8"), ("in_service", "bool"), - ("type", dtype(object))] + return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"), ("qext_w", "f8"), + ("controlled_mdot_kg_per_s", "f8"), ("deltat_k", "f8"), ("treturn_k", "f8"), ("diameter_m", "f8"), + ("in_service", "bool"), ("type", dtype(object))] @classmethod def get_result_table(cls, net): @@ -219,14 +218,13 @@ def get_result_table(cls, net): :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"] + 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"] + 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"] + output += ['deltat_k', 'qext_w'] return output, True @classmethod @@ -246,6 +244,18 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net) - extract_branch_results_without_internals( - net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode - ) + extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, + cls.table_name(), mode) + + node_pit = net['_pit']['node'] + branch_pit = net['_active_pit']['branch'] + branch_lookups = get_lookup(net, "branch", "from_to_active_heat_transfer") + f, t = branch_lookups[cls.table_name()] + + res_table = net["res_" + cls.table_name()] + + res_table['qext_w'].values[:] = branch_pit[f:t, QEXT] + from_nodes = branch_pit[f:t, FROM_NODE_T].astype(int) + t_from = node_pit[from_nodes, TINIT] + tout = branch_pit[f:t, TOUTINIT] + res_table['deltat_k'].values[:] = t_from - tout From 510e04f226067194cba7cca26e8be43a811984ba Mon Sep 17 00:00:00 2001 From: hkoertge Date: Thu, 25 Apr 2024 11:01:55 +0200 Subject: [PATCH 199/237] switched from setup.py to pyproject.toml added change to CHANGELOG.rst version in __init__.py and doc/source/conf.py is now read from pyproject.toml removed content of setup.py removed calls to setup.py in workflows as calling setup.py directly is deprecated --- .github/workflows/release.yml | 11 +++--- CHANGELOG.rst | 6 ++++ doc/source/conf.py | 11 ++++-- pyproject.toml | 65 +++++++++++++++++++++++++++++++++++ setup.py | 54 ++--------------------------- src/pandapipes/__init__.py | 4 ++- 6 files changed, 90 insertions(+), 61 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71bafbf41..423f571a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,14 +38,14 @@ jobs: # Upgrade pip python3 -m pip install --upgrade pip # Install twine - python3 -m pip install setuptools wheel twine + python3 -m pip install build setuptools wheel twine # Upload to TestPyPI - name: Build and Upload to TestPyPI if: ${{ inputs.upload_server == 'testpypi'}} run: | - python3 setup.py sdist --formats=zip - twine check dist/* --strict + python3 -m build + python3 -m twine check dist/* --strict python3 -m twine upload dist/* env: TWINE_USERNAME: __token__ @@ -56,8 +56,8 @@ jobs: - name: Build and Upload to PyPI if: ${{ inputs.upload_server == 'pypi' }} run: | - python3 setup.py sdist --formats=zip - twine check dist/* --strict + python3 -m build + python3 -m twine check dist/* --strict python3 -m twine upload dist/* env: TWINE_USERNAME: __token__ @@ -70,7 +70,6 @@ jobs: time: 300s build: - runs-on: ${{ matrix.os }} needs: upload strategy: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3e79f9eb2..c485275e1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Change Log ============= +[latest] - RELEASEDATE +------------------------------- + +- [CHANGED] switched from setup.py to pyproject.toml + + [0.10.0] - 2024-04-09 ------------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py index 31072d076..687461711 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,6 +12,7 @@ # import os import sys +from sphinx_pyproject import SphinxConfig sys.path.append(os.path.abspath('..')) sys.path.append(os.path.abspath('../..')) @@ -20,9 +21,13 @@ master_doc = 'index' + +# load pyproject.toml configuration +config = SphinxConfig("../../pyproject.toml") + # -- Project information ----------------------------------------------------- -project = 'pandapipes' +project = config.name copyright = '2020-2024 by Fraunhofer Institute for Energy Economics \ and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.' @@ -47,9 +52,9 @@ # built documents. # # The short X.Y version. -version = "0.10" +version = config.version.rsplit(".", 1)[0] # The full version, including alpha/beta/rc tags. -release = "0.10.0" +release = config.version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..b9a698c75 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +requires = ["build", "wheel", "setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "pandapipes" +version = "0.10.0" # File format version '__format_version__' is tracked in __init__.py +authors=[ + { name = "Simon Ruben Drauz-Mauel", email = "simon.ruben.drauz-mauel@iee.fraunhofer.de" }, + { name = "Daniel Lohmeier", email = "daniel.lohmeier@retoflow.de" }, + { name = "Jolando Marius Kisse", email = "jolando.kisse@uni-kassel.de" } +] +description = "A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + # Add the specific Python versions supported here, e.g.: + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12" +] +dependencies = [ + "pandapower ~= 2.14.6", + "matplotlib", + "shapely", +] +keywords = [ + "network", "analysis", "optimization", "automation", "grid", "energy", "engineering", "simulation", "pipeflow", "pandapipes", "gas" +] + +[project.urls] +Homepage = "https://www.pandapipes.org" +Documentation = "https://pandapipes.readthedocs.io" +Source = "https://github.com/e2nIEE/pandapipes" +Repository = "https://github.com/e2nIEE/pandapipes.git" +Issues = "https://github.com/e2nIEE/pandapipes/issues" +Download = "https://pypi.org/project/pandapipes/#files" +Changelog = "https://github.com/e2nIEE/pandapipes/blob/develop/CHANGELOG.rst" + +[project.optional-dependencies] +docs = ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "sphinx-pyproject"] +plotting = ["plotly", "igraph"] +test = ["pytest", "pytest-xdist", "nbmake"] +all = [ + "numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", + "plotly", "igraph", + "pytest", "pytest-xdist", "nbmake" +] + +[tool.setuptools.packages.find] +where = ["src"] +include = ["pandapipes*"] diff --git a/setup.py b/setup.py index b29abc6eb..c44eaf35e 100644 --- a/setup.py +++ b/setup.py @@ -1,57 +1,9 @@ +# -*- coding: utf-8 -*- + # Copyright (c) 2020-2024 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 re - -from setuptools import find_namespace_packages from setuptools import setup -with open('README.rst', 'rb') as f: - install = f.read().decode('utf-8') - -with open('CHANGELOG.rst', 'rb') as f: - changelog = f.read().decode('utf-8') - -classifiers = [ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3'] - -with open('.github/workflows/run_tests_master.yml', 'rb') as f: - lines = f.read().decode('utf-8') - versions = set(re.findall('3.[8-9]', lines)) | set(re.findall('3.1[0-9]', lines)) - for version in versions: - classifiers.append('Programming Language :: Python :: %s' % version) - -long_description = '\n\n'.join((install, changelog)) - -setup( - name='pandapipes', - version='0.10.0', - author='Simon Ruben Drauz-Mauel, Daniel Lohmeier, Jolando Marius Kisse', - author_email='simon.ruben.drauz-mauel@iee.fraunhofer.de, daniel.lohmeier@retoflow.de, ' - 'jolando.kisse@uni-kassel.de', - description='A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids', - long_description=long_description, - long_description_content_type='text/x-rst', - url='http://www.pandapipes.org', - license='BSD', - install_requires=["pandapower>=2.14.6", "matplotlib", "shapely"], - extras_require={"docs": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex"], - "plotting": ["plotly", "igraph"], - "test": ["pytest", "pytest-xdist", "nbmake"], - "all": ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", - "plotly", "igraph", "pytest", "pytest-xdist", "nbmake"]}, - packages=find_namespace_packages(where='src'), - package_dir={"": "src"}, - include_package_data=True, - classifiers=classifiers -) +setup() diff --git a/src/pandapipes/__init__.py b/src/pandapipes/__init__.py index f8e6f2dec..d542f1752 100644 --- a/src/pandapipes/__init__.py +++ b/src/pandapipes/__init__.py @@ -2,7 +2,9 @@ # 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. -__version__ = '0.10.0' +import importlib.metadata + +__version__ = importlib.metadata.version("pandapipes") __format_version__ = '0.10.0' import pandas as pd From a143771e1a53a83440618c6a9de9b0b20bf90a6f Mon Sep 17 00:00:00 2001 From: hkoertge Date: Wed, 15 May 2024 13:22:50 +0200 Subject: [PATCH 200/237] added docs requirements to docs_check pipeline removed explicit install of pandapower master --- .github/workflows/run_tests_develop.yml | 3 +-- .github/workflows/run_tests_master.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index ac4f46a1a..632ee8846 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -147,7 +147,6 @@ jobs: pre-build-command: "apt-get update -y && apt-get install -y git; git --version; python -m pip install --upgrade pip; - python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower; - python -m pip install .['all']" + python -m pip install .[docs];" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 4dd3c27e6..3ddc2cc2b 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -123,7 +123,6 @@ jobs: pre-build-command: "apt-get update -y && apt-get install -y git; git --version; python -m pip install --upgrade pip; - python -m pip install pandapower; - python -m pip install .['all']" + python -m pip install .[docs]" build-command: "sphinx-build -b html source _build -W" docs-folder: "doc/" From b1550518764b5ea970ecef2fbba2c4206014179b Mon Sep 17 00:00:00 2001 From: hkoertge Date: Wed, 15 May 2024 13:35:38 +0200 Subject: [PATCH 201/237] updated docs/requirements.txt --- doc/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 778fafa16..88d2ee075 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,5 @@ sphinx>=5.3.0 sphinx_rtd_theme>=1.1.1 numpydoc>=1.5.0 -sphinxcontrib.bibtex>=2.5.0 \ No newline at end of file +sphinxcontrib.bibtex>=2.5.0 +sphinx-pyproject \ No newline at end of file From 011d3b8bfc03cab2386a8c81d43cd4a3b71b7cdc Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 10 Jun 2024 13:07:37 +0200 Subject: [PATCH 202/237] -added relying and changed build in github test actions --- .github/workflows/run_tests_develop.yml | 39 +++++++++++++++++++++++++ .github/workflows/run_tests_master.yml | 39 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 632ee8846..5c1659fab 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -30,6 +30,45 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install pandapower + python -m pip install . + shell: bash + - name: List all installed packages + run: | + python -m pip list + - name: Test with pytest + if: ${{ matrix.python-version != '3.9' }} + run: | + python -m pytest + - name: Test with pytest and Codecov + if: ${{ matrix.python-version == '3.9' }} + run: | + python -m pip install pytest-cov + python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + if: ${{ matrix.python-version == '3.9' }} + uses: codecov/codecov-action@v1 + with: + verbose: true + + relying: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest igraph pytest-split + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install .["all"] shell: bash diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 3ddc2cc2b..4a6056575 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -39,6 +39,45 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest + - name: Test with pytest and Codecov + if: ${{ matrix.python-version == '3.9' }} + run: | + python -m pip install pytest-cov + python -m pytest --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + if: ${{ matrix.python-version == '3.9' }} + uses: codecov/codecov-action@v1 + with: + verbose: true + + relying: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + os: [ ubuntu-latest, windows-latest ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest igraph pytest-split + if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; + python -m pip install . + shell: bash + - name: List all installed packages + run: | + python -m pip list + - name: Test with pytest + if: ${{ matrix.python-version != '3.9' }} + run: | + python -m pytest - name: Test with numba if: ${{ matrix.python-version == '3.11' }} run: | From c7d743fa2a4c8f0fda632b9c43252fe79d2b3b05 Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 11 Jun 2024 10:09:52 +0200 Subject: [PATCH 203/237] -added src syspath --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 687461711..350b8c5cc 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -18,7 +18,7 @@ sys.path.append(os.path.abspath('../..')) sys.path.append(os.path.abspath('../../..')) sys.path.append(os.path.abspath('../../../pandapower')) - +sys.path.append(os.path.abspath('../../src')) master_doc = 'index' From 4029bd91102725718671db3b0612825d5b41004c Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 11 Jun 2024 10:16:58 +0200 Subject: [PATCH 204/237] -changed readthedocs yml back --- .readthedocs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.readthedocs.yml b/.readthedocs.yml index b6911a40a..202694c89 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,4 +7,6 @@ build: python: install: + - method: pip + path: . - requirements: doc/requirements.txt \ No newline at end of file From 8fa154f79f90025c590ae70722989b9364a4d9c4 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 3 Jun 2024 11:15:31 +0200 Subject: [PATCH 205/237] added workflow trigger --- .github/workflows/run_tests_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 5c1659fab..fa11ef81b 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -11,6 +11,7 @@ on: branches-ignore: [ master ] pull_request: branches-ignore: [ master ] + workflow_dispatch: jobs: build: From ff3e509980925f85eede0939b9e5d19a09ad92a9 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 18 Jun 2024 07:31:00 +0200 Subject: [PATCH 206/237] numpy 2.0 migration --- .../component_models/component_toolbox.py | 2 +- .../converter/stanet/data_cleaning.py | 2 +- .../converter/stanet/preparing_steps.py | 8 +++--- .../converter/stanet/table_creation.py | 28 +++++++++---------- src/pandapipes/pf/internals_toolbox.py | 2 +- src/pandapipes/pf/result_extraction.py | 7 ++--- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 67813dcb9..1c478bd0c 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -88,7 +88,7 @@ def init_results_element(net, element, output, all_float): dtype=np.float64) else: net[res_element] = pd.DataFrame(np.zeros(0, dtype=output), index=[]) - net[res_element] = pd.DataFrame(np.NaN, index=net[element].index, + net[res_element] = pd.DataFrame(np.nan, index=net[element].index, columns=net[res_element].columns) diff --git a/src/pandapipes/converter/stanet/data_cleaning.py b/src/pandapipes/converter/stanet/data_cleaning.py index aa7389530..2aa6db04a 100644 --- a/src/pandapipes/converter/stanet/data_cleaning.py +++ b/src/pandapipes/converter/stanet/data_cleaning.py @@ -20,7 +20,7 @@ def sort_by_pos(group): def sort_by_flow(group): group["follower"] = group.FLUSSB.apply(lambda b: group.index[group.FLUSSA == b][0] - if b in group.FLUSSA.values else np.NaN) + if b in group.FLUSSA.values else np.nan) ls = list(group.loc[~group.FLUSSA.isin(group.FLUSSB)].index) assert len(ls) == 1 while len(ls) < len(group): diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index e423fa5ff..8ddde1917 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -241,7 +241,7 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe node_val = node_geo.loc[pipe_data.loc[pipes_to_check, node_nr].values, node_name].values if pipe_name not in pipe_data.columns: - pipe_data[pipe_name] = np.NaN + pipe_data[pipe_name] = np.nan pipe_data.loc[pipes_to_check, pipe_name] = node_val current_pipe_data = pipe_data.loc[pipes_to_check] if not np.allclose(node_val, current_pipe_data[pipe_name].values): @@ -401,9 +401,9 @@ def connection_pipe_section_table(stored_data, pipe_geodata, house_pipe_geodata, # but requires checks (e.g. positioning on pipe, max. 2 valves per pipe) c2 = stored_data["slider_valves"].loc[:, [c for c in required_columns if c not in ["PRECH", "VMA", "VMB"]]] - c2["PRECH"] = np.NaN - c2["VMA"] = np.NaN - c2["VMB"] = np.NaN + c2["PRECH"] = np.nan + c2["VMA"] = np.nan + c2["VMB"] = np.nan c2["type"] = "slider_valves" connections = pd.concat([connections, c2], ignore_index=True) diff --git a/src/pandapipes/converter/stanet/table_creation.py b/src/pandapipes/converter/stanet/table_creation.py index 280d3a64a..83d6aeb74 100644 --- a/src/pandapipes/converter/stanet/table_creation.py +++ b/src/pandapipes/converter/stanet/table_creation.py @@ -149,9 +149,9 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li j_ref = net.junction.loc[node_mapping[from_stanet_nr], :] j_ref_geodata = net.junction_geodata.loc[node_mapping[from_stanet_nr], :] j_aux = pandapipes.create_junction( - net, np.NaN, tfluid_k=net_params["medium_temp_K"], height_m=j_ref['height_m'], + net, np.nan, tfluid_k=net_params["medium_temp_K"], height_m=j_ref['height_m'], name='aux_' + j_ref['stanet_id'], geodata=(j_ref_geodata.x, j_ref_geodata.y), - stanet_nr=-999, stanet_id='aux_' + j_ref['stanet_id'], p_stanet=np.NaN, + stanet_nr=-999, stanet_id='aux_' + j_ref['stanet_id'], p_stanet=np.nan, stanet_active=bool(row.ISACTIVE), **add_info ) text_k = 293 @@ -169,7 +169,7 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li net, j_aux, node_mapping[to_stanet_nr], diameter_m=float(row.DM / 1000), opened=row.AUF == 'J', loss_coefficient=0, name="valve_%s_%s" % ('aux_' + str(row.ENDNAM), str(row.ENDNAM)), - stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=np.NaN, + stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=np.nan, stanet_active=bool(row.ISACTIVE), **add_info ) @@ -382,7 +382,7 @@ def create_control_components(net, stored_data, index_mapping, net_params, add_l drop_eg = net.ext_grid.loc[net.ext_grid.junction.isin(to_junctions[is_pc])].index net.ext_grid.drop(drop_eg, inplace=True) - net.junction.loc[to_junctions[is_pc], "pn_bar"] = np.NaN + net.junction.loc[to_junctions[is_pc], "pn_bar"] = np.nan pandapipes.reindex_elements(net, "ext_grid", np.arange(len(net.ext_grid))) if np.any(is_fc): @@ -463,7 +463,7 @@ def create_junctions_from_connections(net, connection_table, net_params, index_m continue stanet_ids = cons.STANETID.astype(str).values stanet_nrs = cons.RECNO.astype(np.int32).values - p_stanet = cons.PRECH.astype(np.float64).values if houses_in_calculation else np.NaN + p_stanet = cons.PRECH.astype(np.float64).values if houses_in_calculation else np.nan names = stanet_ids if con_type not in extend_from_to else \ stanet_ids + node_type.replace(con_type, "") geo = np.array([cons.geo.apply(lambda g: g[0]), cons.geo.apply(lambda g: g[1])]).transpose() @@ -475,7 +475,7 @@ def create_junctions_from_connections(net, connection_table, net_params, index_m if add_layers: add_info["stanet_layer"] = cons.LAYER.values.astype(str) pp_indices = pandapipes.create_junctions( - net, len(cons), np.NaN, net_params["medium_temp_K"], name=names, + net, len(cons), np.nan, net_params["medium_temp_K"], name=names, height_m=cons.GEOH.astype(np.float64).values, geodata=geo, type=cons.type.values, in_service=in_service, stanet_nr=stanet_nrs, stanet_id=stanet_ids, p_stanet=p_stanet, stanet_system=cons.CLIENTTYP.replace(CLIENT_TYPES_OF_PIPES).values, @@ -798,13 +798,13 @@ def build_house_junctions(net, index_mapping, hh_types, hh_recno, house_table, m add_info["stanet_layer"] = connected_houses.LAYER.values.astype(str) # create junctions for houses that are directly connected via house pipes pp_ind = pandapipes.create_junctions( - net, len(connected_houses), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(connected_houses), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=heights_houses.astype(np.float64), geodata=geodata, in_service=houses_in_calculation, name=["house_%s" % hn for hn in connected_houses.RECNO.values], type="house", stanet_nr=connected_houses.RECNO.values, stanet_id=connected_houses.STANETID.values.astype(str), - p_stanet=connected_houses.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=connected_houses.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=connected_houses.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -827,13 +827,13 @@ def build_meter_junctions(net, index_mapping, hh_types, hh_recno, meter_table, n add_info["stanet_layer"] = connected_meters.LAYER.values.astype(str) # create junctions for meters that are directly connected via house pipes pp_ind = pandapipes.create_junctions( - net, len(connected_meters), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(connected_meters), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=connected_meters.GEOH.values.astype(np.float64), name=connected_meters.STANETID.values.astype(str), geodata=geodata, type="meter", stanet_nr=connected_meters.RECNO.values, stanet_id=connected_meters.STANETID.astype(str), in_service=houses_in_calculation, - p_stanet=connected_meters.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=connected_meters.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=connected_meters.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -853,12 +853,12 @@ def build_house_node_junctions(net, index_mapping, stored_data, net_params, hous if add_layers: add_info["stanet_layer"] = house_nodes.LAYER.values.astype(str) pp_ind = pandapipes.create_junctions( - net, len(house_node_nrs), np.NaN, tfluid_k=net_params["medium_temp_K"], + net, len(house_node_nrs), np.nan, tfluid_k=net_params["medium_temp_K"], height_m=house_nodes.GEOH.values.astype(np.float64), name=house_nodes.STANETID.values.astype(str), geodata=geodata, type="house_node", stanet_nr=house_node_nrs, stanet_id=house_nodes.STANETID.astype(str), in_service=houses_in_calculation, - p_stanet=house_nodes.PRECH.values if houses_in_calculation else np.NaN, + p_stanet=house_nodes.PRECH.values if houses_in_calculation else np.nan, stanet_system=CLIENT_TYPES_OF_PIPES[HOUSE_PIPE_TYPE], stanet_active=house_nodes.ISACTIVE.values.astype(np.bool_), stanet_valid=houses_in_calculation, **add_info @@ -1091,7 +1091,7 @@ def create_sinks_meters(net, meter_table, index_mapping, net_params, add_layers) assigned_node_nums = meter_table.KNONUM.astype(np.int32) meter_nrs = meter_table.RECNO.astype(np.int32) - junctions_assigned = pd.Series([node_mapping.get(nn, np.NaN) for nn in assigned_node_nums], + junctions_assigned = pd.Series([node_mapping.get(nn, np.nan) for nn in assigned_node_nums], index=meter_table.index, dtype=float) junctions_connected = pd.Series(index=meter_table.index, dtype=float) @@ -1110,7 +1110,7 @@ def create_sinks_meters(net, meter_table, index_mapping, net_params, add_layers) if np.any(junctions_connected.isnull()): junctions_connected.loc[junctions_connected.isnull()] = \ - [node_mapping.get(n, np.NaN) if not np.isnan(n) else np.NaN for n in + [node_mapping.get(n, np.nan) if not np.isnan(n) else np.nan for n in meter_table.KNONUM.loc[junctions_connected.isnull()].values] logger.warning("The meters %s cannot be mapped to a house connection node and will be " "assigned to nodes %s" diff --git a/src/pandapipes/pf/internals_toolbox.py b/src/pandapipes/pf/internals_toolbox.py index 8e094476f..a1e0db5f7 100644 --- a/src/pandapipes/pf/internals_toolbox.py +++ b/src/pandapipes/pf/internals_toolbox.py @@ -44,7 +44,7 @@ def _sum_by_group_sorted(indices, *values): val[i] = val[i][index] still_na = nans[index] val[i][1:] = val[i][1:] - val[i][:-1] - val[i][still_na] = np.NaN + val[i][still_na] = np.nan else: np.cumsum(val[i], out=val[i]) val[i] = val[i][index] diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 6a4b616a0..624a62dc8 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -290,13 +290,10 @@ def extract_results_active_pit(net, mode="hydraulics"): not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] - amb = get_net_option(net, 'ambient_temperature') - - net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN if mode == "hydraulics" else amb + net["_pit"]["node"][~nodes_connected, result_node_col] = np.nan net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN if mode == "hydraulics" else \ - net["_pit"]["branch"][~branches_connected, TEXT] + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.nan net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols] From 1f0ca1e4b3da4684cc145db1b44434c169a39308 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Tue, 18 Jun 2024 07:38:49 +0200 Subject: [PATCH 207/237] remove workflow_dispatch --- .github/workflows/run_tests_develop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index fa11ef81b..5c1659fab 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -11,7 +11,6 @@ on: branches-ignore: [ master ] pull_request: branches-ignore: [ master ] - workflow_dispatch: jobs: build: From 3ec84b890b6e6b74763db0e9a669aa44874ef2c3 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 12:00:24 +0200 Subject: [PATCH 208/237] fixed some merge bugs. --- .github/workflows/run_tests_develop.yml | 9 ++--- .github/workflows/run_tests_master.yml | 52 +++---------------------- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 5c1659fab..cd2d479e8 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -58,16 +58,15 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install pytest igraph pytest-split - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install .["all"] @@ -83,7 +82,7 @@ jobs: if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install numba - python -m pytest + python -m pytest -n=auto - name: Test with pytest and Codecov if: ${{ matrix.python-version == '3.9' }} run: | @@ -155,7 +154,7 @@ jobs: python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower - python -m pip install . + python -m pip install .["all"] shell: bash - name: List all installed packages run: | diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 417aeb7a5..6891298a3 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -39,45 +39,6 @@ jobs: if: ${{ matrix.python-version != '3.9' }} run: | python -m pytest - - name: Test with pytest and Codecov - if: ${{ matrix.python-version == '3.9' }} - run: | - python -m pip install pytest-cov - python -m pytest --cov=./ --cov-report=xml - - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} - uses: codecov/codecov-action@v1 - with: - verbose: true - - relying: - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - os: [ ubuntu-latest, windows-latest ] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pytest igraph pytest-split - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install pandapower; - python -m pip install . - shell: bash - - name: List all installed packages - run: | - python -m pip list - - name: Test with pytest - if: ${{ matrix.python-version != '3.9' }} - run: | - python -m pytest - name: Test with numba if: ${{ matrix.python-version == '3.11' }} run: | @@ -119,19 +80,17 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ ubuntu-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest igraph pytest-split - if [${{ matrix.python-version != '3.11' }}]; then python -m pip install numba; fi + python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower; - python -m pip install . + python -m pip install .["all"] shell: bash - name: List all installed packages run: | @@ -139,7 +98,7 @@ jobs: - name: Test with pytest if: ${{ matrix.python-version != '3.9' }} run: | - python -m pytest + python -m pytest -n=auto tutorial_tests: runs-on: ${{ matrix.os }} @@ -158,7 +117,6 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install pandapower python -m pip install .["all"] shell: bash - name: List all installed packages From 564f026a5509f99cfe436bf938364c2f1bf1e1e0 Mon Sep 17 00:00:00 2001 From: mvogt Date: Tue, 25 Jun 2024 14:58:59 +0200 Subject: [PATCH 209/237] fixed the result extraction, seems to be broken during the rebase. --- src/pandapipes/pf/result_extraction.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 624a62dc8..6a4b616a0 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -290,10 +290,13 @@ def extract_results_active_pit(net, mode="hydraulics"): not_affected_branch_col]]) rows_branches = np.arange(net["_pit"]["branch"].shape[0])[branches_connected] - net["_pit"]["node"][~nodes_connected, result_node_col] = np.nan + amb = get_net_option(net, 'ambient_temperature') + + net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN if mode == "hydraulics" else amb net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.nan + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN if mode == "hydraulics" else \ + net["_pit"]["branch"][~branches_connected, TEXT] net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols] From 103b75b59c96530f4f532010fac77fb92658f331 Mon Sep 17 00:00:00 2001 From: EPrade <90843651+EPrade@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:15:54 +0200 Subject: [PATCH 210/237] -fixed heat consumer result extraction (#636) * -fixed heat consumer result extraction * -added test --- .../heat_consumer_component.py | 4 ++-- .../api/test_components/test_heat_consumer.py | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 367caf239..6228abead 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -248,8 +248,8 @@ def extract_results(cls, net, options, branch_results, mode): cls.table_name(), mode) node_pit = net['_pit']['node'] - branch_pit = net['_active_pit']['branch'] - branch_lookups = get_lookup(net, "branch", "from_to_active_heat_transfer") + branch_pit = net['_pit']['branch'] + branch_lookups = get_lookup(net, "branch", "from_to") f, t = branch_lookups[cls.table_name()] res_table = net["res_" + cls.table_name()] diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 029a52123..c6a782aff 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -187,6 +187,27 @@ def test_heat_consumer_qext_zero(): assert net.res_junction.at[juncs[4], 't_k'] != 263.4459264973806 +def test_heat_consumer_result_extraction(): + net = pandapipes.create_empty_network("net", add_stdtypes=False, fluid="water") + + juncs = pandapipes.create_junctions(net, 6, pn_bar=5, tfluid_k=286, system=["flow"] * 3 + ["return"] * 3) + pandapipes.create_pipes_from_parameters(net, juncs[[0, 1, 3, 4]], juncs[[1, 2, 4, 5]], k_mm=0.1, length_km=1, + diameter_m=0.1022, system=["flow"] * 2 + ["return"] * 2, alpha_w_per_m2k=10, + text_k=273.15) + pandapipes.create_circ_pump_const_pressure(net, juncs[-1], juncs[0], 5, 2, 300, type='pt') + pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, treturn_k=263.4459264973806, qext_w=7500) + pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=1, qext_w=7500) + + # create not connected pipe to test for active inactive missmatch + pandapipes.create_junctions(net, 2, pn_bar=5, tfluid_k=286) + pandapipes.create_pipe_from_parameters(net, 6, 7, k_mm=0.1, length_km=1, + diameter_m=0.1022, alpha_w_per_m2k=10, text_k=273.15) + + pandapipes.pipeflow(net, mode="bidirectional", iter=25, alpha=0.5) + + #hydraulics only to check for lookup heat transfer error + pandapipes.pipeflow(net) + if __name__ == '__main__': pytest.main([__file__]) From 0cb374ee16b58a74a3ccb25ff9a66a16c235060b Mon Sep 17 00:00:00 2001 From: eprade Date: Fri, 28 Jun 2024 13:49:58 +0200 Subject: [PATCH 211/237] -implemented warning changes and convert format change --- src/pandapipes/create.py | 10 ++++++++-- src/pandapipes/io/convert_format.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index e08bf306c..f427a7edd 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,6 +4,7 @@ import numpy as np import pandas as pd +import warnings from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ _check_branch_element, _check_multiple_branch_elements @@ -429,6 +430,10 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, _check_branch(net, "Pipe", index, from_junction, to_junction) _check_std_type(net, std_type, "pipe", "create_pipe") + if "alpha_w_per_m2k" in kwargs: + warnings.warn("The parameter alpha_w_per_m2k has been renamed to u_w_per_m2k. U is extracted from the std_type" + , DeprecationWarning) + pipe_parameter = load_std_type(net, std_type, "pipe") v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": std_type, "length_km": length_km, "diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm, @@ -506,7 +511,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam if u_w_per_m2k == 0: u_w_per_m2k = kwargs['alpha_w_per_m2k'] - raise DeprecationWarning(' In the future alpha will be renamed to u') + warnings.warn("The parameter alpha_w_per_m2k has been renamed to u_w_per_m2k." "It will be removed in future.", + DeprecationWarning) v = {"name": name, "from_junction": from_junction, "to_junction": to_junction, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, @@ -1422,7 +1428,7 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d if u_w_per_m2k == 0: u_w_per_m2k = kwargs['alpha_w_per_m2k'] - raise DeprecationWarning(' In the future alpha will be renamed to u') + warnings.warn("The parameter alpha_w_per_m2k has been renamed to u_w_per_m2k." "It will be removed in future.", DeprecationWarning) entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, diff --git a/src/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py index 430b982a5..becd8ffc1 100644 --- a/src/pandapipes/io/convert_format.py +++ b/src/pandapipes/io/convert_format.py @@ -46,7 +46,7 @@ def _rename_columns(net): net['controller'].drop('controller', inplace=True, axis=1) net["controller"].rename(columns={"controller": "object"}, inplace=True) if "pipe" in net: - if "u_w_per_m2k" not in net["pipe"]: + if "u_w_per_m2k" not in net["pipe"].columns: net["pipe"].rename(columns={"alpha_w_per_m2k": "u_w_per_m2k"}, inplace=True) for comp in [CirculationPumpMass, CirculationPumpPressure]: cp_tbl = comp.table_name() From a07f86345b51db90826068fd2ccef0dddf203bfd Mon Sep 17 00:00:00 2001 From: eprade Date: Fri, 28 Jun 2024 13:58:14 +0200 Subject: [PATCH 212/237] -added import --- src/pandapipes/create.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index f427a7edd..6fc19f849 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -4,6 +4,7 @@ import numpy as np import pandas as pd +from pandapower.auxiliary import _preserve_dtypes import warnings from pandapower.create import _get_multiple_index_with_check, _get_index_with_check, _set_entries, \ _check_node_element, _check_multiple_node_elements, _set_multiple_entries, \ From 319e83c25dd8faecc7274f5bf409fdafba44e6c0 Mon Sep 17 00:00:00 2001 From: eprade Date: Fri, 28 Jun 2024 14:37:56 +0200 Subject: [PATCH 213/237] -added tests --- .../{test_pipe_results.py => test_pipe.py} | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) rename src/pandapipes/test/api/test_components/{test_pipe_results.py => test_pipe.py} (78%) diff --git a/src/pandapipes/test/api/test_components/test_pipe_results.py b/src/pandapipes/test/api/test_components/test_pipe.py similarity index 78% rename from src/pandapipes/test/api/test_components/test_pipe_results.py rename to src/pandapipes/test/api/test_components/test_pipe.py index 60c978e40..4d9d624eb 100644 --- a/src/pandapipes/test/api/test_components/test_pipe_results.py +++ b/src/pandapipes/test/api/test_components/test_pipe.py @@ -6,7 +6,7 @@ import pandapipes from pandapipes.properties.fluids import _add_fluid_to_net - +import copy @pytest.mark.parametrize("use_numba", [True, False]) def test_pipe_velocity_results(use_numba): @@ -73,3 +73,30 @@ def test_pipe_velocity_results(use_numba): assert np.all(np.abs(diff_from) < 1e-9) assert np.all(np.abs(diff_to) < 1e-9) + +@pytest.fixture +def create_empty_net(): + return pandapipes.create_empty_network() + +def test_namechange_pipe_from_parameters(create_empty_net): + net = copy.deepcopy(create_empty_net) + length_km = 1 + diameter_m = 0.01 + alpha = 5 + j1 = pandapipes.create_junction(net, 3, 273) + j2 = pandapipes.create_junction(net, 3, 273) + with pytest.warns(DeprecationWarning): + pandapipes.create_pipe_from_parameters(net, 0, 1, length_km, diameter_m, alpha_w_per_m2k=alpha) + assert net.pipe.u_w_per_m2k.values == alpha + +def test_namechange_pipes_from_parameters(create_empty_net): + net = copy.deepcopy(create_empty_net) + length_km = 1 + diameter_m = 0.01 + alpha = [5,3] + j1 = pandapipes.create_junction(net, 3, 273) + j2 = pandapipes.create_junction(net, 3, 273) + j3 = pandapipes.create_junction(net, 3, 273) + with pytest.warns(DeprecationWarning): + pandapipes.create_pipes_from_parameters(net, [0,1], [1,2], length_km, diameter_m, alpha_w_per_m2k=alpha) + assert net.pipe.u_w_per_m2k.values.tolist() == alpha \ No newline at end of file From 314d0bf51a2d7db521f7144d9ea6f298beaa760d Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:27:23 +0200 Subject: [PATCH 214/237] in create_pipes_from_parameters, the check for the value of u_w_per_m2k in case of existing alpha is corrected (exception for given arrays of u) (#637) --- src/pandapipes/component_models/__init__.py | 1 + .../component_models/component_toolbox.py | 2 +- src/pandapipes/create.py | 10 ++-- .../test/api/test_components/test_pipe.py | 49 ++++++++++++------- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/pandapipes/component_models/__init__.py b/src/pandapipes/component_models/__init__.py index 3437b0c3a..3b3f54c50 100644 --- a/src/pandapipes/component_models/__init__.py +++ b/src/pandapipes/component_models/__init__.py @@ -16,3 +16,4 @@ from pandapipes.component_models.compressor_component import * from pandapipes.component_models.flow_control_component import * from pandapipes.component_models.mass_storage_component import * +from pandapipes.component_models.heat_consumer_component import * diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 1c478bd0c..b90a1fba2 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -215,8 +215,8 @@ def get_component_array(net, component_name, component_type="branch", mode='hydr :return: component_array - internal array of the component :rtype: numpy.ndarray """ - f_all, t_all = get_lookup(net, component_type, "from_to")[component_name] if not only_active: return net["_pit"]["components"][component_name] + f_all, t_all = get_lookup(net, component_type, "from_to")[component_name] in_service_elm = get_lookup(net, component_type, "active_%s"%mode)[f_all:t_all] return net["_pit"]["components"][component_name][in_service_elm] diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index 6fc19f849..c3347359c 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -1,6 +1,7 @@ # Copyright (c) 2020-2024 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. +from typing import Iterable import numpy as np import pandas as pd @@ -1426,10 +1427,12 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d if 'alpha_w_per_m2k' in kwargs: - if u_w_per_m2k == 0: + if (not isinstance(u_w_per_m2k, Iterable) and isinstance(u_w_per_m2k, float) + and u_w_per_m2k == 0.): u_w_per_m2k = kwargs['alpha_w_per_m2k'] - warnings.warn("The parameter alpha_w_per_m2k has been renamed to u_w_per_m2k." "It will be removed in future.", DeprecationWarning) + warnings.warn("The parameter alpha_w_per_m2k has been renamed to u_w_per_m2k." + "It will be removed in future.", DeprecationWarning) entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions, "std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm, @@ -1437,9 +1440,6 @@ def create_pipes_from_parameters(net, from_junctions, to_junctions, length_km, d "sections": sections, "in_service": in_service, "type": type, "qext_w": qext_w, "text_k": text_k} - - - if 'std_type' in kwargs: raise UserWarning('you have defined a std_type, however, using this function you can only ' 'create a pipe setting specific, individual parameters. If you want to ' diff --git a/src/pandapipes/test/api/test_components/test_pipe.py b/src/pandapipes/test/api/test_components/test_pipe.py index 4d9d624eb..171d2aecf 100644 --- a/src/pandapipes/test/api/test_components/test_pipe.py +++ b/src/pandapipes/test/api/test_components/test_pipe.py @@ -8,6 +8,7 @@ from pandapipes.properties.fluids import _add_fluid_to_net import copy + @pytest.mark.parametrize("use_numba", [True, False]) def test_pipe_velocity_results(use_numba): """ @@ -38,9 +39,10 @@ def test_pipe_velocity_results(use_numba): compressibility=1, der_compressibility=0, density=0.82752 )) max_iter_hyd = 5 if use_numba else 5 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, - use_numba=use_numba) + pandapipes.pipeflow( + net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", + transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba + ) v_1_sec_from = net.res_pipe.v_from_m_per_s v_1_sec_to = net.res_pipe.v_from_m_per_s @@ -61,7 +63,8 @@ def test_pipe_velocity_results(use_numba): name="natural_gas", fluid_type="gas", viscosity=11.93e-6, heat_capacity=2185, compressibility=1, der_compressibility=0, density=0.82752 )) - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, friction_model="nikuradse", + pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, + friction_model="nikuradse", transient=False, nonlinear_method="automatic", tol_p=1e-5, tol_m=1e-5, use_numba=use_numba) @@ -74,29 +77,37 @@ def test_pipe_velocity_results(use_numba): assert np.all(np.abs(diff_from) < 1e-9) assert np.all(np.abs(diff_to) < 1e-9) + @pytest.fixture -def create_empty_net(): - return pandapipes.create_empty_network() +def create_net_3_juncs(): + net = pandapipes.create_empty_network() + pandapipes.create_junctions(net, 3, 3, 273) + return net -def test_namechange_pipe_from_parameters(create_empty_net): - net = copy.deepcopy(create_empty_net) + +def test_namechange_pipe_from_parameters(create_net_3_juncs): + net = copy.deepcopy(create_net_3_juncs) length_km = 1 diameter_m = 0.01 alpha = 5 - j1 = pandapipes.create_junction(net, 3, 273) - j2 = pandapipes.create_junction(net, 3, 273) with pytest.warns(DeprecationWarning): - pandapipes.create_pipe_from_parameters(net, 0, 1, length_km, diameter_m, alpha_w_per_m2k=alpha) + pandapipes.create_pipe_from_parameters(net, 0, 1, length_km, diameter_m, + alpha_w_per_m2k=alpha) assert net.pipe.u_w_per_m2k.values == alpha -def test_namechange_pipes_from_parameters(create_empty_net): - net = copy.deepcopy(create_empty_net) + +def test_namechange_pipes_from_parameters(create_net_3_juncs): + net = copy.deepcopy(create_net_3_juncs) length_km = 1 diameter_m = 0.01 - alpha = [5,3] - j1 = pandapipes.create_junction(net, 3, 273) - j2 = pandapipes.create_junction(net, 3, 273) - j3 = pandapipes.create_junction(net, 3, 273) + alpha = [5, 3] + with pytest.warns(DeprecationWarning): + pandapipes.create_pipes_from_parameters(net, [0, 1], [1, 2], length_km, diameter_m, + alpha_w_per_m2k=alpha) + assert net.pipe.u_w_per_m2k.values.tolist() == alpha + net = copy.deepcopy(create_net_3_juncs) + u = [1, 7] with pytest.warns(DeprecationWarning): - pandapipes.create_pipes_from_parameters(net, [0,1], [1,2], length_km, diameter_m, alpha_w_per_m2k=alpha) - assert net.pipe.u_w_per_m2k.values.tolist() == alpha \ No newline at end of file + pandapipes.create_pipes_from_parameters(net, [0, 1], [1, 2], length_km, diameter_m, + alpha_w_per_m2k=alpha, u_w_per_m2k=np.array(u)) + assert net.pipe.u_w_per_m2k.values.tolist() == u From 0e48f527acdbe728e4883bbd5bd3fa2d3cc616b6 Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 4 Jul 2024 14:03:37 +0200 Subject: [PATCH 215/237] -changed junction into flow junction for circ pumps --- src/pandapipes/plotting/pipeflow_results.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index bc32fc810..23c20f619 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -92,9 +92,15 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control if x0_junctions is None: x0_junctions = set(net.ext_grid[net.ext_grid.in_service].junction.values) if hasattr(net, "circ_pump_pressure"): - x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].junction.values) + x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].flow_junction.values) + warn(UserWarning( + f'For circ pumps, if no x0_junctions are given the flow junctions is chosen automatically:' + f' {x0_junctions}')) if hasattr(net, "circ_pump_mass"): - x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].junction.values) + x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].flow_junction.values) + warn(UserWarning( + f'For circ pumps, if no x0_junctions are given the flow junctions is chosen automatically:' + f' {x0_junctions}')) x0_junctions = list(x0_junctions) unsupplied_junctions = list(top.unsupplied_junctions(net, slacks=set(x0_junctions))) From 869a1649e35e7c3a81f9735b860da7e817d7d360 Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 4 Jul 2024 14:07:23 +0200 Subject: [PATCH 216/237] -wording and changelog --- CHANGELOG.rst | 1 + src/pandapipes/plotting/pipeflow_results.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1cbeb4981..4e3bcbf68 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Change Log -[ADDED] heat_consumer plotting -[CHANGED] switched from setup.py to pyproject.toml - [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" +- [FIXED] Pressure plot not working for circ pump - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index 23c20f619..78a5141a9 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -94,12 +94,12 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control if hasattr(net, "circ_pump_pressure"): x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].flow_junction.values) warn(UserWarning( - f'For circ pumps, if no x0_junctions are given the flow junctions is chosen automatically:' + f'For circ pumps, if no x0_junctions are given the flow junctions are chosen automatically:' f' {x0_junctions}')) if hasattr(net, "circ_pump_mass"): x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].flow_junction.values) warn(UserWarning( - f'For circ pumps, if no x0_junctions are given the flow junctions is chosen automatically:' + f'For circ pumps, if no x0_junctions are given the flow junctions are chosen automatically:' f' {x0_junctions}')) x0_junctions = list(x0_junctions) From 12cf554b12f2a9a2ab3e41cfa6590de26903d1fc Mon Sep 17 00:00:00 2001 From: eprade Date: Thu, 4 Jul 2024 14:18:13 +0200 Subject: [PATCH 217/237] -removed warning and moved the hint to docstring --- src/pandapipes/plotting/pipeflow_results.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pandapipes/plotting/pipeflow_results.py b/src/pandapipes/plotting/pipeflow_results.py index 78a5141a9..a7a64f3b1 100644 --- a/src/pandapipes/plotting/pipeflow_results.py +++ b/src/pandapipes/plotting/pipeflow_results.py @@ -54,7 +54,7 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control axis to plot to, by default None x0_junctions : Any[list[int], pd.Index[int]], optional list of junction indices which should be at position x0. If None, all in service slack junctions are considered, - by default None + by default None. For circ pumps, if no x0_junctions are given the flow junctions are chosen automatically. plot_pressure_controller : bool, optional Whether vertical lines should be plotted to display the pressure drop of the pressure controller, by default True @@ -93,14 +93,8 @@ def plot_pressure_profile(net, ax=None, x0_junctions=None, plot_pressure_control x0_junctions = set(net.ext_grid[net.ext_grid.in_service].junction.values) if hasattr(net, "circ_pump_pressure"): x0_junctions |= set(net.circ_pump_pressure[net.circ_pump_pressure.in_service].flow_junction.values) - warn(UserWarning( - f'For circ pumps, if no x0_junctions are given the flow junctions are chosen automatically:' - f' {x0_junctions}')) if hasattr(net, "circ_pump_mass"): x0_junctions |= set(net.circ_pump_mass[net.circ_pump_mass.in_service].flow_junction.values) - warn(UserWarning( - f'For circ pumps, if no x0_junctions are given the flow junctions are chosen automatically:' - f' {x0_junctions}')) x0_junctions = list(x0_junctions) unsupplied_junctions = list(top.unsupplied_junctions(net, slacks=set(x0_junctions))) From 12c8256e6a8aa6b31c9aa4973e452a70934fc6c4 Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:18:40 +0200 Subject: [PATCH 218/237] small doc fix as raised by issue #562 (#641) --- doc/source/components/sink/sink_par.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/components/sink/sink_par.csv b/doc/source/components/sink/sink_par.csv index 1326571fa..541d982c5 100644 --- a/doc/source/components/sink/sink_par.csv +++ b/doc/source/components/sink/sink_par.csv @@ -1,7 +1,7 @@ **Parameter**;**Datatype**;**Value Range**;**Explanation** name;string;;Name of the sink junction;integer;;Index of connected junction -mdot_kg_per_s;float;:math:`\leq 0`;Drawn mass flow [kg/s] +mdot_kg_per_s;float;:math:`\geq 0`;Drawn mass flow [kg/s] scaling *;float;:math:`\geq 0`;Scaling factor to adapt the drawn mass flow in_service*;boolean;True / False;Specifies if the sink is in service. type;string;;Component type From 7afa6f654869bdd300f117876d1a718f44494f54 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 19 Aug 2024 16:06:18 +0200 Subject: [PATCH 219/237] differentiate between vdot and vdot_norm in result extraction, depending on fluid type --- .../component_models/component_toolbox.py | 7 +- .../flow_control_component.py | 2 +- .../heat_consumer_component.py | 2 +- .../heat_exchanger_component.py | 2 +- .../component_models/pipe_component.py | 9 +- .../pressure_control_component.py | 9 +- .../component_models/pump_component.py | 9 +- .../component_models/valve_component.py | 2 +- .../converter/stanet/preparing_steps.py | 2 +- .../valve_pipe_component.py | 2 +- tutorials/height_difference_example.ipynb | 596 ++++++++++++++++-- 11 files changed, 550 insertions(+), 92 deletions(-) diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index b90a1fba2..e9a633fe9 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -183,8 +183,7 @@ def get_mass_flow_at_nodes(net, node_pit, branch_pit, eg_nodes, comp): def standard_branch_wo_internals_result_lookup(net): required_results_hyd = [ ("p_from_bar", "p_from"), ("p_to_bar", "p_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") + ("mdot_from_kg_per_s", "mf_from"), ("lambda", "lambda"), ("reynolds", "reynolds") ] required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] @@ -192,10 +191,10 @@ def standard_branch_wo_internals_result_lookup(net): required_results_hyd.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") + ("normfactor_to", "normfactor_to"), ("vdot_norm_m3_per_s", "vf") ]) else: - required_results_hyd.extend([("v_mean_m_per_s", "v_mps")]) + required_results_hyd.extend([("v_mean_m_per_s", "v_mps"), ("vdot_m3_per_s", "vf")]) return required_results_hyd, required_results_ht diff --git a/src/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py index fbcf909d1..c4aff33b8 100644 --- a/src/pandapipes/component_models/flow_control_component.py +++ b/src/pandapipes/component_models/flow_control_component.py @@ -129,6 +129,6 @@ def get_result_table(cls, net): "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", + "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 6228abead..4b750c85a 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -223,7 +223,7 @@ def get_result_table(cls, net): "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"] + "mdot_to_kg_per_s", "vdot_m3_per_s", "reynolds", "lambda"] output += ['deltat_k', 'qext_w'] return output, True diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index cbcaef46f..b4f510cb2 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -111,6 +111,6 @@ def get_result_table(cls, net): "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", + "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 98d6232af..68a56a263 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -133,17 +133,16 @@ def extract_results(cls, net, options, branch_results, mode): res_nodes_from_ht = [("t_from_k", "temp_from")] res_nodes_to_hyd = [("p_to_bar", "p_to"), ("mdot_to_kg_per_s", "mf_to")] res_nodes_to_ht = [("t_to_k", "temp_to")] - res_mean_hyd = [("vdot_norm_m3_per_s", "vf"), ("lambda", "lambda"), - ("reynolds", "reynolds")] + res_mean_hyd = [("lambda", "lambda"), ("reynolds", "reynolds")] if get_fluid(net).is_gas: res_nodes_from_hyd.extend([("v_from_m_per_s", "v_gas_from"), ("normfactor_from", "normfactor_from")]) res_nodes_to_hyd.extend([("v_to_m_per_s", "v_gas_to"), ("normfactor_to", "normfactor_to")]) - res_mean_hyd.extend([("v_mean_m_per_s", "v_gas_mean")]) + res_mean_hyd.extend([("v_mean_m_per_s", "v_gas_mean"), ("vdot_norm_m3_per_s", "vf")]) else: - res_mean_hyd.extend([("v_mean_m_per_s", "v_mps")]) + res_mean_hyd.extend([("v_mean_m_per_s", "v_mps"), ("vdot_m3_per_s", "vf")]) if np.any(cls.get_internal_pipe_number(net) > 1): extract_branch_results_with_internals( @@ -299,7 +298,7 @@ def get_result_table(cls, net): "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", + "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py index b2e5b3de1..205d2af12 100644 --- a/src/pandapipes/component_models/pressure_control_component.py +++ b/src/pandapipes/component_models/pressure_control_component.py @@ -96,17 +96,18 @@ def extract_results(cls, net, options, branch_results, mode): """ required_results_hyd = [ ("p_from_bar", "p_from"), ("p_to_bar", "p_to"), ("mdot_from_kg_per_s", "mf_from"), - ("mdot_to_kg_per_s", "mf_to"), ("vdot_norm_m3_per_s", "vf") + ("mdot_to_kg_per_s", "mf_to") ] required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] if get_fluid(net).is_gas: required_results_hyd.extend([ ("v_from_m_per_s", "v_gas_from"), ("v_to_m_per_s", "v_gas_to"), - ("normfactor_from", "normfactor_from"), ("normfactor_to", "normfactor_to") + ("normfactor_from", "normfactor_from"), ("normfactor_to", "normfactor_to"), + ("vdot_norm_m3_per_s", "vf") ]) else: - required_results_hyd.extend([("v_mean_m_per_s", "v_mps")]) + required_results_hyd.extend([("v_mean_m_per_s", "v_mps"), ("vdot_m3_per_s", "vf")]) extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode) @@ -154,6 +155,6 @@ def get_result_table(cls, net): "vdot_norm_m3_per_s", "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"] + "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s"] output += ["deltap_bar"] return output, True diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index eeaa8938e..4a05bd0bb 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -138,17 +138,18 @@ def extract_results(cls, net, options, branch_results, mode): required_results_hyd = [ ("p_from_bar", "p_from"), ("p_to_bar", "p_to"), ("mdot_to_kg_per_s", "mf_to"), - ("mdot_from_kg_per_s", "mf_from"), ("vdot_norm_m3_per_s", "vf"), ("deltap_bar", "pl"), + ("mdot_from_kg_per_s", "mf_from"), ("deltap_bar", "pl"), ] required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] if get_fluid(net).is_gas: required_results_hyd.extend([ ("v_from_m_per_s", "v_gas_from"), ("v_to_m_per_s", "v_gas_to"), - ("normfactor_from", "normfactor_from"), ("normfactor_to", "normfactor_to") + ("normfactor_from", "normfactor_from"), ("normfactor_to", "normfactor_to"), + ("vdot_norm_m3_per_s", "vf") ]) else: - required_results_hyd.extend([("v_mean_m_per_s", "v_mps")]) + required_results_hyd.extend([("v_mean_m_per_s", "v_mps"), ("vdot_m3_per_s", "vf")]) extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode) @@ -224,7 +225,7 @@ def get_result_table(cls, net): # TODO: inwieweit sind diese Angaben bei imaginärem Durchmesser sinnvoll? else: output = ["deltap_bar", "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"] + "t_to_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s"] if calc_compr_pow: output += ["compr_power_mw"] diff --git a/src/pandapipes/component_models/valve_component.py b/src/pandapipes/component_models/valve_component.py index b88403361..2b13e8613 100644 --- a/src/pandapipes/component_models/valve_component.py +++ b/src/pandapipes/component_models/valve_component.py @@ -91,6 +91,6 @@ def get_result_table(cls, net): "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", + "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index 8ddde1917..ec8fdbb8e 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -245,7 +245,7 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe pipe_data.loc[pipes_to_check, pipe_name] = node_val current_pipe_data = pipe_data.loc[pipes_to_check] if not np.allclose(node_val, current_pipe_data[pipe_name].values): - wrong_data = ~np.isclose(node_val, current_pipe_data[pipe_name].values) + wrong_data = ~np.isclose(node_val, current_pipe_data[pipe_name].values, rtol=1e-10) df = pd.DataFrame( {"pipe_%s_%s" % (coord, locat): current_pipe_data[pipe_name].values[wrong_data], "node_%s_%s" % (coord, locat): node_val[wrong_data]}, index=pipe_rec[wrong_data] diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py index 311a84d9f..538995466 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py @@ -114,7 +114,7 @@ def get_result_table(cls, net): "p_to_mw", "mdot_from_kg_per_s", "mdot_to_kg_per_s", - "vdot_norm_m3_per_s", + "vdot_m3_per_s", "reynolds", "lambda", "loading_percent"] diff --git a/tutorials/height_difference_example.ipynb b/tutorials/height_difference_example.ipynb index 324a1b8f6..eb989f3d9 100644 --- a/tutorials/height_difference_example.ipynb +++ b/tutorials/height_difference_example.ipynb @@ -33,23 +33,32 @@ }, { "cell_type": "code", - "execution_count": 1, "metadata": { - "scrolled": true + "scrolled": true, + "ExecuteTime": { + "end_time": "2024-08-19T14:00:37.229949Z", + "start_time": "2024-08-19T14:00:35.528051Z" + } }, - "outputs": [], "source": [ "import pandapipes as pp" - ] + ], + "outputs": [], + "execution_count": 1 }, { "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:37.270307Z", + "start_time": "2024-08-19T14:00:37.252995Z" + } + }, "source": [ "net = pp.create_empty_network(fluid=\"water\") # create an empty network" - ] + ], + "outputs": [], + "execution_count": 2 }, { "cell_type": "markdown", @@ -67,16 +76,21 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:41.636793Z", + "start_time": "2024-08-19T14:00:41.620514Z" + } + }, "source": [ "junction1 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 352, name=\"Junction 1\")\n", "junction2 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 358, name=\"Junction 2\")\n", "junction3 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 361, name=\"Junction 3\")\n", "junction4 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 346, name=\"Junction 4\")\n", "junction5 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, height_m = 400, name=\"Junction 5\")" - ] + ], + "outputs": [], + "execution_count": 3 }, { "cell_type": "markdown", @@ -87,22 +101,110 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:46.600384Z", + "start_time": "2024-08-19T14:00:46.586735Z" + } + }, + "source": [ + "net.junction # show junction table" + ], "outputs": [ { "data": { - "text/plain": " name pn_bar tfluid_k height_m in_service type\n0 Junction 1 1.0 293.15 352.0 True junction\n1 Junction 2 1.0 293.15 358.0 True junction\n2 Junction 3 1.0 293.15 361.0 True junction\n3 Junction 4 1.0 293.15 346.0 True junction\n4 Junction 5 1.0 293.15 400.0 True junction", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namepn_bartfluid_kheight_min_servicetype
0Junction 11.0293.15352.0Truejunction
1Junction 21.0293.15358.0Truejunction
2Junction 31.0293.15361.0Truejunction
3Junction 41.0293.15346.0Truejunction
4Junction 51.0293.15400.0Truejunction
\n
" + "text/plain": [ + " name pn_bar tfluid_k height_m in_service type\n", + "0 Junction 1 1.0 293.15 352.0 True junction\n", + "1 Junction 2 1.0 293.15 358.0 True junction\n", + "2 Junction 3 1.0 293.15 361.0 True junction\n", + "3 Junction 4 1.0 293.15 346.0 True junction\n", + "4 Junction 5 1.0 293.15 400.0 True junction" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namepn_bartfluid_kheight_min_servicetype
0Junction 11.0293.15352.0Truejunction
1Junction 21.0293.15358.0Truejunction
2Junction 31.0293.15361.0Truejunction
3Junction 41.0293.15346.0Truejunction
4Junction 51.0293.15400.0Truejunction
\n", + "
" + ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "net.junction # show junction table" - ] + "execution_count": 4 }, { "cell_type": "markdown", @@ -127,24 +229,72 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:49.779695Z", + "start_time": "2024-08-19T14:00:49.770055Z" + } + }, + "source": [ + "medium_pressure_grid = pp.create_ext_grid(net, junction=junction5, p_bar=0.5, t_k=293.15, name=\"Grid Connection\")\n", + "\n", + "net.ext_grid # show external grid table" + ], "outputs": [ { "data": { - "text/plain": " name junction p_bar t_k in_service type\n0 Grid Connection 4 0.5 293.15 True pt", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namejunctionp_bart_kin_servicetype
0Grid Connection40.5293.15Truept
\n
" + "text/plain": [ + " name junction p_bar t_k in_service type\n", + "0 Grid Connection 4 0.5 293.15 True pt" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namejunctionp_bart_kin_servicetype
0Grid Connection40.5293.15Truept
\n", + "
" + ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "medium_pressure_grid = pp.create_ext_grid(net, junction=junction5, p_bar=0.5, t_k=293.15, name=\"Grid Connection\")\n", - "\n", - "net.ext_grid # show external grid table" - ] + "execution_count": 5 }, { "cell_type": "markdown", @@ -164,15 +314,20 @@ }, { "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:53.731512Z", + "start_time": "2024-08-19T14:00:53.716223Z" + } + }, "source": [ "pipe1 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction2, length_km=0.545, diameter_m=0.2, name=\"Pipe 1\")\n", "pipe2 = pp.create_pipe_from_parameters(net, from_junction=junction2, to_junction=junction3, length_km=0.095, diameter_m=0.15, name=\"Pipe 2\")\n", "pipe3 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction4, length_km=0.285, diameter_m=0.15, name=\"Pipe 3\")\n", "pipe4 = pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction5, length_km=0.43, diameter_m=0.15, k_mm=0.5, name=\"Pipe 4\")" - ] + ], + "outputs": [], + "execution_count": 6 }, { "cell_type": "markdown", @@ -183,22 +338,146 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:00:57.958470Z", + "start_time": "2024-08-19T14:00:57.948328Z" + } + }, + "source": [ + "net.pipe # show pipe table" + ], "outputs": [ { "data": { - "text/plain": " name from_junction to_junction std_type length_km diameter_m k_mm \\\n0 Pipe 1 0 1 None 0.545 0.20 1.0 \n1 Pipe 2 1 2 None 0.095 0.15 1.0 \n2 Pipe 3 0 3 None 0.285 0.15 1.0 \n3 Pipe 4 0 4 None 0.430 0.15 0.5 \n\n loss_coefficient u_w_per_m2k text_k qext_w sections in_service \\\n0 0.0 0.0 293.0 0.0 1 True \n1 0.0 0.0 293.0 0.0 1 True \n2 0.0 0.0 293.0 0.0 1 True \n3 0.0 0.0 293.0 0.0 1 True \n\n type \n0 pipe \n1 pipe \n2 pipe \n3 pipe ", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
namefrom_junctionto_junctionstd_typelength_kmdiameter_mk_mmloss_coefficientu_w_per_m2ktext_kqext_wsectionsin_servicetype
0Pipe 101None0.5450.201.00.00.0293.00.01Truepipe
1Pipe 212None0.0950.151.00.00.0293.00.01Truepipe
2Pipe 303None0.2850.151.00.00.0293.00.01Truepipe
3Pipe 404None0.4300.150.50.00.0293.00.01Truepipe
\n
" + "text/plain": [ + " name from_junction to_junction std_type length_km diameter_m k_mm \\\n", + "0 Pipe 1 0 1 None 0.545 0.20 0.2 \n", + "1 Pipe 2 1 2 None 0.095 0.15 0.2 \n", + "2 Pipe 3 0 3 None 0.285 0.15 0.2 \n", + "3 Pipe 4 0 4 None 0.430 0.15 0.5 \n", + "\n", + " loss_coefficient u_w_per_m2k text_k qext_w sections in_service type \n", + "0 0.0 0.0 NaN 0.0 1 True pipe \n", + "1 0.0 0.0 NaN 0.0 1 True pipe \n", + "2 0.0 0.0 NaN 0.0 1 True pipe \n", + "3 0.0 0.0 NaN 0.0 1 True pipe " + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namefrom_junctionto_junctionstd_typelength_kmdiameter_mk_mmloss_coefficientu_w_per_m2ktext_kqext_wsectionsin_servicetype
0Pipe 101None0.5450.200.20.00.0NaN0.01Truepipe
1Pipe 212None0.0950.150.20.00.0NaN0.01Truepipe
2Pipe 303None0.2850.150.20.00.0NaN0.01Truepipe
3Pipe 404None0.4300.150.50.00.0NaN0.01Truepipe
\n", + "
" + ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "net.pipe # show pipe table" - ] + "execution_count": 7 }, { "cell_type": "markdown", @@ -257,16 +536,20 @@ }, { "cell_type": "code", - "execution_count": 9, "metadata": { "pycharm": { "name": "#%%\n" + }, + "ExecuteTime": { + "end_time": "2024-08-19T14:01:16.329041Z", + "start_time": "2024-08-19T14:01:12.912139Z" } }, - "outputs": [], "source": [ "pp.pipeflow(net, friction_model=\"nikuradse\")" - ] + ], + "outputs": [], + "execution_count": 8 }, { "cell_type": "markdown", @@ -281,49 +564,215 @@ }, { "cell_type": "code", - "execution_count": 10, "metadata": { "pycharm": { "name": "#%%\n" + }, + "ExecuteTime": { + "end_time": "2024-08-19T14:01:24.515012Z", + "start_time": "2024-08-19T14:01:24.508487Z" } }, + "source": [ + "net.res_junction # calculated pressure and temperature at junctions" + ], "outputs": [ { "data": { - "text/plain": " p_bar t_k\n0 5.194289 293.15\n1 4.607432 293.15\n2 4.314000 293.15\n3 5.780977 293.15\n4 0.500000 293.15", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
p_bart_k
05.194289293.15
14.607432293.15
24.314000293.15
35.780977293.15
40.500000293.15
\n
" + "text/plain": [ + " p_bar t_k\n", + "0 5.194647 293.15\n", + "1 4.607818 293.15\n", + "2 4.314403 293.15\n", + "3 5.781476 293.15\n", + "4 0.500000 293.15" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
p_bart_k
05.194647293.15
14.607818293.15
24.314403293.15
35.781476293.15
40.500000293.15
\n", + "
" + ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "net.res_junction # calculated pressure and temperature at junctions" - ] + "execution_count": 9 }, { "cell_type": "code", - "execution_count": 11, "metadata": { "pycharm": { "name": "#%%\n" + }, + "ExecuteTime": { + "end_time": "2024-08-19T14:01:28.266605Z", + "start_time": "2024-08-19T14:01:28.253169Z" } }, + "source": [ + "net.res_pipe # velocities, mass flows through pipes and other results" + ], "outputs": [ { "data": { - "text/plain": " v_mean_m_per_s p_from_bar p_to_bar t_from_k t_to_k mdot_from_kg_per_s \\\n0 0.004433 5.194289 4.607432 293.15 293.15 0.139 \n1 0.007880 4.607432 4.314000 293.15 293.15 0.139 \n2 0.015704 5.194289 5.780977 293.15 293.15 0.277 \n3 -0.023584 5.194289 0.500000 293.15 293.15 -0.416 \n\n mdot_to_kg_per_s vdot_norm_m3_per_s reynolds lambda \n0 -0.139 0.000139 886.106589 0.102569 \n1 -0.139 0.000139 1181.475451 0.087337 \n2 -0.277 0.000278 2354.451079 0.060350 \n3 0.416 -0.000417 3535.926531 0.045036 ", - "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
v_mean_m_per_sp_from_barp_to_bart_from_kt_to_kmdot_from_kg_per_smdot_to_kg_per_svdot_norm_m3_per_sreynoldslambda
00.0044335.1942894.607432293.15293.150.139-0.1390.000139886.1065890.102569
10.0078804.6074324.314000293.15293.150.139-0.1390.0001391181.4754510.087337
20.0157045.1942895.780977293.15293.150.277-0.2770.0002782354.4510790.060350
3-0.0235845.1942890.500000293.15293.15-0.4160.416-0.0004173535.9265310.045036
\n
" + "text/plain": [ + " v_mean_m_per_s p_from_bar p_to_bar t_from_k t_to_k mdot_from_kg_per_s \\\n", + "0 0.0 5.194647 4.607818 293.15 293.15 0.0 \n", + "1 0.0 4.607818 4.314403 293.15 293.15 0.0 \n", + "2 0.0 5.194647 5.781476 293.15 293.15 0.0 \n", + "3 0.0 5.194647 0.500000 293.15 293.15 0.0 \n", + "\n", + " mdot_to_kg_per_s vdot_m3_per_s reynolds lambda \n", + "0 -0.0 0.0 0.0 0.019623 \n", + "1 -0.0 0.0 0.0 0.021072 \n", + "2 -0.0 0.0 0.0 0.021072 \n", + "3 -0.0 0.0 0.0 0.026936 " + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
v_mean_m_per_sp_from_barp_to_bart_from_kt_to_kmdot_from_kg_per_smdot_to_kg_per_svdot_m3_per_sreynoldslambda
00.05.1946474.607818293.15293.150.0-0.00.00.00.019623
10.04.6078184.314403293.15293.150.0-0.00.00.00.021072
20.05.1946475.781476293.15293.150.0-0.00.00.00.021072
30.05.1946470.500000293.15293.150.0-0.00.00.00.026936
\n", + "
" + ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "net.res_pipe # velocities, mass flows through pipes and other results" - ] + "execution_count": 10 }, { "cell_type": "markdown", @@ -336,8 +785,18 @@ }, { "cell_type": "code", - "execution_count": 12, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2024-08-19T14:01:39.084519Z", + "start_time": "2024-08-19T14:01:38.996816Z" + } + }, + "source": [ + "import matplotlib\n", + "from pandapipes.plotting.simple_plot import simple_plot as sp\n", + "\n", + "sp(net, plot_sinks = True)" + ], "outputs": [ { "name": "stderr", @@ -348,27 +807,26 @@ }, { "data": { - "text/plain": "
", - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAs8AAAIrCAYAAAAQp3QjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXpElEQVR4nO3dW2je933H8Y9k2Tr4mMSH2IndyHLBs0ObZKSjgy2MMXqT26xQWBk7EBgbu9rFYFc7wHpVdoJdjMK2boNCb8q2ix1gY2OweW3SdG2cTbbkOHYUy7FjW/FBkfXsQrHrJJb9lfScn9cLDEbP38//6wuht/7P7//7DzUajUYAAICHGu70AAAA0CvEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAG9FodHoCoI3EMwCs1fvvJ1/5SnLgQLJpUzIxkfz8zyf/93+dngxosaFGw6/MAFB27Vry+c8np08nN2788OubNiXj48k//MPK60BfEs8AsBYvv5z8+Z8nt27d//Xdu5O3305GRto7F9AWlm0AQNX77ydf//rq4ZwkN28mf/u37ZsJaCvxDABV09MPv6K8sJCcONGeeYC2E88AULVlSxq3bz/4mOHhZMuW9swDtJ14BoCChYWFfH9pKR9s3vzgA8fGkhdfbM9QQNuJZwB4gIWFhXz/+9/Pt7/97Vy8dClnvvzlLI+P3/fYxshIcvx48qM/2uYpgXZxKzAA3MfCwkLOnDmTixcvJkmGhoZy4MCBHPzKVzK8vJx87WsrNw5+uIxjaXw8i3v3ZvRb38qmTg4OtJSt6gDgHqtG88GDGR0d/eGBr72W/NEfJf/zP2k89lhO/dRP5dwzz+RTU1N56qmnOjM80HLiGQCyhmhexXvvvZfvfve7GR4ezvPPP5+xsbFWjwx0gHgGYKBtNJrv9YMf/CDz8/PZs2dPjh071opxgQ6z5hmAgdTMaL7j8OHDeffddzM/P58rV65k586dqx7baDQyNDS0rvMAnePKMwADpRXRfK/Z2dmcOXMm27Zty3PPPfeJQF5aWsqZM2dy/vz5TE5O5sknn9zwOYH2ceUZgIHQ6mi+4+DBg5mbm8vCwkLm5uayf//+JCtXmufm5jIzM5MPPvggSXL16tWmnRdoD/EMQF9rVzTfsWnTpkxOTubkyZOZmZnJnj17srCwkFOnTmVhYSFJsnnz5rsBDfQW8QxAX2p3NN9r7969OX/+fK5evZrvfOc7uXHjRpJkdHQ0hw8fTqPRyMmTJ1s6A9Aa4hmAvtLJaL5jeXk5ExMTuXr1am7cuJGhoaEcOnQoBw8ezKZNm3LhwoW2zAE0n3gGoC90QzQ3Go3Mz8/n9OnTuXXrVpJkYmIiTz/9dMZXeaQ30FvEMwA9rRuiOUmuXbuW6enpuzcBbtu2LUeOHHngdnVA7xHPAPSkbonm27dvZ3p6OnNzc0lWbgacnJzM448/bh9n6EPiGYCe0i3RfMf8/PzdcB4dHc2zzz7bkTmA9hDPAPSEbovmO3bv3p1Lly5lfn4+t27dyiuvvJLJycns3bvXlWfoQ+IZgK7WrdF8x8jISI4dO5b33nvv7l7OJ0+ezPnz53PkyJFs37690yMCTSSeAehK3R7NH7dr164899xzd58ieGeP58cffzyTk5PZsmVLp0cEmkA8A9BVei2a7zU0NJT9+/dnz549OXPmTM6dO5e5ubnMz8/n0KFDefLJJzM8PNzpMYENEM8AdIVejuaPGxkZydTUVPbv35/Tp0/n3XffzczMTN5+++1MTU2l0Wh0ekRgnYYavoMB6KB+iubVXLp0KadOncr169eTJFu2bMni4mL27NmTY8eOdXg6YC1ceQagIwYhmu949NFHs2vXrrz99tuZnZ3N4uJip0cC1kk8A9BWgxTN9xoeHs4TTzyRvXv3ZnZ2NufPn7cTB/QgyzYAaItBjebVLC8vu3kQepB4BqClRDPQTyzbAKAlRDPQj8QzAE0lmoF+Jp4BaArRDAwC8QzAhohmYJCIZwDWRTQDg0g8A7AmohkYZOIZgBLRDCCeAXgI0QzwQ+IZgPsSzQCfJJ4B+AjRDLA68QxAEtEMUCGeAQacaAaoE88AA0o0A6ydeAYYMKIZYP3EM8CAEM0AGyeeAfqcaAZoHvEM0KdEM0DziWeAPiOaAVpHPAP0CdEM0HriGaDHiWaA9hHPAD1KNAO0n3gG6DGiGaBzxDNAjxDNAJ0nngG6nGgG6B7iGaBLiWaA7iOeAbqMaAboXuIZoEuIZoDuJ54BOkw0A/QO8QzQIaIZoPeIZ4A2E80AvUs8A7SJaAbofeIZoMVEM0D/EM8ALSKaAfqPeAZoMtEM0L/EM0CTiGaA/ieeATZINAMMDvEMsE6iGWDwiGeANRLNAINLPAMUiWYAxDPAQ4hmAO4QzwCrEM0AfJx4BvgY0QzAasQzwIdEMwAPI56BgSeaAagSz8DAEs0ArJV4BgaOaAZgvcQzMDBEMwAbJZ6BvieaAWgW8Qz0LdEMQLOJZ6DviGYAWkU8A31DNAPQauIZ6HmiGYB2Ec9AzxLNALSbeAZ6jmgGoFPEM9AzRDMAnSaega4nmgHoFuIZ6FqiGYBuI56BriOaAehW4hnoGqIZgG4nnoGOE80A9ArxDHSMaAag14hnoO1EMwC9SjwDbSOaAeh14hloOdEMQL8Qz0DLiGYA+o14BppONAPQr8Qz0DSiGYB+J56BDRPNAAwK8Qysm2gGYNCIZ2DNRDMAg0o8A2WiGYBBJ56BhxLNALBCPAOrEs0A8FGtiedv7EiWrm3sPUa2Jz97tTnzAGsimgHg/loTzxsN52a9B7AmohkAHsyyDUA0A0CReIYBJpoBYG3EM/Sba9eSr389+eY3kw8+SH76p5OXX0727bt7iGgGgPUZajQajaa/618PNed9vtT80aCv/fd/Jz/zMyvR/P77K18bG0uGhpK//MssfOELohkANkA8Q7+4fDmZnEyuXLnvy8tjY/nOH/9x3j9yRDQDwDpZtgH94mtfW7nivJrFxRz6m7/J1T/9U9EMAOvU1Vee//WJf2nK+8AgeO7ll7P9jTceeExj27YMXbMNJACs13CnBwCaY2hx8eEHLS21fhAA6GNdvWzjhRde6PQI0Du+8IXkz/7sgYF8/fDhLF6+nF27dmVoqEn3JgDAAHHlGfrFr/96snnzqi/fHhvL7Be/mNdeey2vvvpqLl++nFas2gKAfiaeoV8cPZr83u8lExOffG3r1gy99FK2ffnLGRkZydWrV0U0AKxDV98waKs6WId//ufkd34n+bd/SxqN5Nix5Dd/M/nSl5KhoSwtLeXcuXN56623svThEo8dO3bkqaeespwDAB5CPEO/ajRW/gzf/wMmEQ0AayeeYcCJaACoE89AEhENABXiGfgIEQ0Aq2tNPH9jR7K0waeYjWxPfvZqc+YB1kxEA8AntSaegb4hogHgh8QzUCKiAUA8A2skogEYZOIZWBcRDcAgEs/AhohoAAaJeAaaQkQDMAjEM9BUIhqAfiaegZYQ0QD0I/EMtJSIBqCfiGegLUQ0AP1APANtJaIB6GXiGegIEQ1ALxLPQEeJaAB6iXgGuoKIBqAXiGegq4hoALqZeAa6kogGoBuJZ6CriWgAuol4BnqCiAagG4hnoKeIaAA6STwDPUlEA9AJ4hnoaSIagHYSz0BfENEAtIN4BvqKiAaglcQz0JdENACtIJ6BviaiAWgm8QwMBBENQDOIZ2CgiGgANkI8AwNJRAOwHuIZGGgiGoC1EM8AEdEA1IhngHuIaAAeRDwD3IeIBuB+xDPAA4hoAO4lngEKRDQAiXgGWBMRDTDYxDPAOohogMEkngE2QEQDDBbxDNAEIhpgMIhngCYS0QD9TTwDtICIBuhP4hmghUQ0QH8RzwBtIKIB+oN4BmgjEQ3Q28QzQAeIaIDeJJ4BOkhEA/QW8QzQBZaWlnL+/PmcPXtWRAN0MfEM0EVENEB3E88AXUhEA3Qn8QzQxUQ0QHcRzwA9QEQDdAfxDNBDRDRAZ4lngB4kogE6QzwD9DARDdBe4hmgD4hogPYQzwB9REQDtJZ4BuhDIhqgNcQzQB8T0QDNJZ4BBoCIBmgO8QwwQEQ0wMaIZ4ABJKIB1kc8AwwwEQ2wNuIZABENUCSeAbhLRAM8mHgG4BNENMD9iWcAViWiAT5KPAPwUCIaYIV4BqBMRAODTjwDsGYiGhhU4hmAdRPRwKARzwBsmIgGBoV4BqBpRDTQ78QzAE0nooF+JZ4BaBkRDfQb8QxAy4looF+IZwDaRkQDvU48A9B2IhroVeIZgI4R0UCvEc8AdJyIBnqFeAaga4hooNuJZwC6jogGupV4BqBriWig24hnALqeiAa6hXgGoGeIaKDTxDMAPUdEA50ingHoWSIaaDfxDEDPE9FAu4hnAPqGiAZaTTwD0HdENNAq4hmAviWigWYTzwD0PRENNIt4BmBgiGhgo8QzAANHRAPrJZ4BGFgiGlgr8QzAwBPRQJV4BoAPrSmib99O/umfkunpZOfO5MUXk127OjM49LMLF5K///vk+vXk+PHkJ38y6eAvtOIZAD7moRH9j/+Y/NzPJTduJB98kIyMJEtLya/9WvL7v58MD3f4fwB9YHEx+ZVfSf7qr1a+x27fTjZtSh59NPnGN5If+7GOjCWeAWAV94vo/adO5dO/+qsZunHjk/9gYiL5pV9K/uAP2jwp9KGXXkr+7u9Wfkn9uK1bk//8z5Ur0W0mngHgIe6N6M/8wi9k+//+7+oHj44mMzPJ/v3tGxD6zfe+t3Jl+X7hnKws23jxxeRb32rvXBHPAFC2NDOT4R/5kQzfurXqMbe3bMnML/9yzr30Uhsng/5y+E/+JE9885sZXl5e/aAtW5LLl1c+8Wkji7IAoGjkvfcyPDr6wGM2LS5m8+XLbZoI+tPo/PyDwzlZWf985Up7BrrHSNvPCAC96sCB5AFXnZMkExP51E/8RD71wgvtmQn60Y//ePIf/7Fy0+BqGo3kkUfaN9OHXHkGgKp9+1Z+qD/I8nLyxS+2Zx7oV7/4iw/etWbTppUbCsfG2jfTh8QzAKzFH/5hsm3b/V+bmEh++7c7cjUM+srhw8nLL993PfPy0FAaO3Ykv/u7HRhMPAPA2jz9dPLv/54888zKD/YdO5Lt25PHHku++tXkN36j0xNCf/jqV5Pf+q2V77EdO5KdO7M8OpqrTz+dk3/xF2kcPNiRsey2AQDrdfJkcurUyhMGP//5lY+SgeZaXFxZ//z++/ng05/Of83PZ2lpKcePH8/u3bvbPo54BgCgZ5w7dy7T09MZGxvL888/n+E2P9HTsg0AAHrGgQMHsnXr1ty8eTNvvfVW288vngEA6BlDQ0OZmppKkpw5cya3HrB95LVr13LhwoU0c6GFfZ4BAOgpjzzySB577LG8++67mZmZydGjRz/y+q1btzIzM5N33nknSTIxMZFtq+2Ss0biGQCAnjM1NZVLly7lnXfeyYEDB7Jjx44sLy/n7NmzefPNN7N8zxMKb9++3bTzWrYBAEDPGR8fz5NPPpkkmZ6ezoULF3LixInMzs5meXk5u3fvzvj4eNPPK54BAOhJhw4dysjISK5du5bXX389N2/ezNatW/OZz3wmx48fz+bNm5t+Tss2AADoOYuLi5mdnc3S0lKSlRsJjxw5kv3792doaKhl5xXPAAD0jOXl5Zw/fz6zs7N31zLv2bMnhw8fztjYWMvPL54BAOgJly5dyqlTp3L9+vUkK7tuTE1NZevWrW2bQTwDAND1pqenc+7cuSQrNwtOTU3l0UcfbekSjftxwyAAAF3v5s2bd/8+Pj6eiYmJtodzIp4BAOgBx44dy+TkZIaHh3Pp0qWcOHEip0+fvnvDYLuIZwAAut7w8HAOHTqUz33uc9m3b18ajUbOnj2bEydOZG5urqmP4H7gHG05CwAANMHo6GiOHj2aZ599Ntu3b8/i4mLeeOONvPLKK7ly5UrLzy+eAQDoOTt27Mizzz6bo0ePZsuWLbl27VpeffXVvP7667l161bLzmu3DQAAetLQ0FD27duX3bt3580338zZs2dz4cKFXLx4MYcOHcry8nLzz9lo1wIRAABooRs3buT06dO5ePHiR77+zDPPZOfOnU05h2UbAAD0hfHx8Rw/fjyf/exnP/LglGZuaefKMwAAfafRaGRubi7Xr1+/u8VdM4hnAAAosmwDAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF4hkAAIrEMwAAFIlnAAAoEs8AAFAkngEAoEg8AwBAkXgGAIAi8QwAAEXiGQAAisQzAAAUiWcAACgSzwAAUCSeAQCgSDwDAECReAYAgCLxDAAAReIZAACKxDMAABSJZwAAKBLPAABQJJ4BAKBIPAMAQJF4BgCAIvEMAABF/w/7XHqLXDEdYgAAAABJRU5ErkJggg==\n" + "text/plain": [ + "
" + ], + "image/png": "iVBORw0KGgoAAAANSUhEUgAAA+gAAAMDCAYAAAAxID+lAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAdFklEQVR4nO3d3Y9ddb3H8e/MtKUlB6ikkRCTtlpPkQtL4wkP3hiIjxc8xJIYQ4IXEvSP8B8BxRtvCIEIiTYhECOosSoKpEaKBXIaQBAvSHk4KmVm9rnYDPZhZrpnZq+1P2ut1yuZdO+dtWd/983KvLvW+q250Wg0KgAAAGCm5mc9AAAAACDQAQAAIIJABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AgIsbjaqeeqrqrruqDh+uOnSo6siRqqNHq5aWZj0dQC/MjUaj0ayHAAAg2IsvVt15Z9ULL1Rt21a1uDh+fWFhHOd791Y9/HDVDTfMdk6AjhPoAACs7a9/rbrppqr33lv7SPnCQtX27VW//OV4WwA2RaADALC60ajq858fR/rKUfO1LCxU7dlT9eqrVTt2tDMfQM+4Bh0AgNX95jdVf/nLxeO8anx0/a23qh57rPGxAPpKoAMAsLoHHhhfcz6phYWq++5rbh6AnhPoAACs7sSJyY6er1haqjp5srl5AHpOoAMAsLrNLFVkeSOATRPoAACs6sz+/TVaWJj8DfPzVQcONDcQQM8JdAAAznH69Ol6/vnn68QXv1hza91abTXLy1Xf+15zgwH0nNusAQBQVeMwP3XqVL3zzjvjF0ajuv7uu2vXG2/U3PLy+m+en6/6xCeqXn+9aufO5ocF6CGBDgAwcBeE+Ud27dpVB95/v6687baa++CD8SJwq5mfH/888UTVLbe0MDFAPwl0AICBWi/M9+3bV5/85Cdrbm6u6vnnq26/veq118a3UlsJ9ZXHe/ZUPfxw1c03t/4dAPpEoAMADMzEYX62paWqo0er7r9/fPu15eXxgnD33lt15EjVjh0tfgOAfhLoAAADsakwB6A122Y9AAAAzRLmAN0g0AEAekqYA3SLQAcA6BlhDtBNAh0AoCeEOUC3CXQAgI4T5gD9INABADpKmAP0i0AHAOgYYQ7QTwIdAKAjhDlAvwl0AIBwwhxgGAQ6AEAoYQ4wLAIdACCMMAcYJoEOABBCmAMMm0AHAJgxYQ5AlUAHAJgZYQ7A2QQ6AEDLhDkAqxHoAAAtEeYArEegAwA0TJgDMAmBDgDQEGEOwEYIdACAKRPmAGyGQAcAmBJhDsBWCHQAgC0S5gBMg0AHANgkYQ7ANAl0AIANEuYANEGgAwBMSJgD0CSBDgBwEcIcgDYIdACANQhzANok0AEAziPMAZgFgQ4A8BFhDsAsCXQAYPCEOQAJBDoAMFjCHIAkAh0AGBxhDkAigQ4ADIYwByCZQAcAek+YA9AFAh0A6C1hDkCXCHQAoHeEOQBdJNABgN4Q5gB0mUAHADpPmAPQBwIdAOgsYQ5Anwh0AKBzhDkAfSTQAYDOEOYA9JlABwDiCXMAhkCgAwCxhDkAQyLQAYA4whyAIRLoAEAMYQ7AkAl0AGDmhDkACHQAYIaEOQD8h0AHAFonzAHgQgIdAGiNMAeAtQl0AKBxwhwALk6gAwCNEeYAMDmBDgBMnTAHgI0T6ADA1AhzANg8gQ4AbJkwB4CtE+gAwKYJcwCYHoEOAGyYMAeA6RPoAMDEhDkANEegAwAXJcwBoHkCHQBYkzAHgPYIdADgAsIcANon0AGAjwlzAJgdgQ4ACHMACCDQAWDAhDkA5BDoADBAwhwA8gh0ABgQYQ4AuQQ6AAyAMAeAfAIdAHpMmANAdwh0AOghYQ4A3SPQAaBHhDkAdJdAB4AeEOYA0H0CHQA6TJgDQH8IdADoIGEOAP0j0AGgQ4Q5APSXQAeADhDmANB/Ah0AgglzABgOgQ4AgYQ5AAyPQAeAIMIcAIZLoANAAGEOAAh0AJghYQ4ArBDoADADwhwAOJ9AB4AWCXMAYC0CHQBaIMwBgIsR6ADQIGEOAExKoANAA4Q5ALBRAh0ApkiYAwCbJdABYAqEOQCwVQIdALZAmAMA0yLQAWAThDkAMG0CHQA2QJgDAE0R6AAwAWEOADRNoAPAOoQ5ANAWgQ4AqxDmAEDbBDoAnEWYAwCzItABoIQ5ADB7Ah2AQRPmAEAKgQ7AIAlzACCNQAdgUIQ5AJBKoAMwCMIcAEgn0AHoNWEOAHSFQAegl4Q5ANA1Ah2AXhHmAEBXCXQAekGYAwBdJ9AB6DRhDgD0hUAHoJOEOQDQNwIdgE4R5gBAXwl0ADpBmAMAfSfQAYgmzAGAoRDoAEQS5gDA0Ah0AKIIcwBgqAQ6ABGEOQAwdAIdgJkS5gAAYwIdgJkQ5gAA5xLoALRKmAMArE6gA9AKYQ4AsD6BDkCjhDkAwGQEOgCNEOYAABsj0AGYKmEOALA5Ah2AqRDmAABbI9AB2BJhDgAwHQIdgE0R5gAA0yXQAdgQYQ4A0AyBDsBEhDkAQLMEOgDrEuYAAO0Q6ACsSpgDALRLoANwDmEOADAbAh2AqhLmAACzJtABBk6YAwBkEOgAAyXMAQCyCHSAgRHmAACZBDrAQAhzAIBsAh2g54Q5AEA3CHSAnhLmAADdItABekaYAwB0k0AH6AlhDgDQbbMJ9Hdfqlp8r7nfv+2yqsv/u7nfDxBEmAMA9EP7gf7uS1U/P9j859x6UqQDvSbMAQD6pf1Ab/LI+Sw+B6BlwhwAoJ9cgw7QEcIcAKDfBDpAOGEOADAMAh0glDAHABgWgQ7QpNGo6qmnqu67r+r48aqlpar9+6u++92qI0eqduy44C3CHABgmAQ6QFNefrnqjjuqXnihatu2qsXF8euvvFL15JNVe/ZUPfhg1Ve+UlXCHABg6AQ6QBNeeaXqxhur3n13/HwlzquqlpfH/779dtU3vlHvP/RQvXzggDAHABg4gQ7QhLvuGsf52WF+vuXlGs3N1c7vfKfee+SRqksvrSphDgAwVAIdYNqefbbqD3+YaNO50agW/vnPuurJJ+v0t78tzAEABmx+1gMA9M6Pfzy+5nxSc3P16SeeqOuvv76uuuoqcQ4AMFC9PYJ+/Pjx+r9LPpj1GMAAXfvHP9bu9U5tP8/caFTbX321SpgDAAxabwP9ww8/rDNzZ2Y9BjBAyyuLwAEAwAb0NtC3b99eO1a5vzBA087s3VvLzz1X80tLE20/mpurxb17a9to5PR2AIAB622gHzp0qOrKL8x6DGCIfvCDqp/+dPLtR6P63699rU4/84xF4gAABswicQDT9oUvVN1ww0QLxY3m5mrp0kvrra9+tf71r3/Viy++WM8880y99dZbNRqNWhgWAIAUAh2gCQ8+WHX55etH+vx8zc3P179/8pO67OqrP35ZqAMADJNAB2jCZz5T9fvfVx08OH5+dqjPf7TrvfLKqscfr/+68846fPhwXXfddXXFFVd8vJlQBwAYlrlR23/xvf1s1eP/0/znfONPrkEHZm80qnr66ar77qv685+rFher9u2ruueeqm9+s2qVxSxPnz5dp06dqnfeeeec13ft2uUadQCAHhPoAKGEOgDAsDjFHSDU7t27nfoOADAgAh0gnFAHABgGgQ7QEUIdAKDfBDpAxwh1AIB+an+RuHdfqvr5weY/59aTVZf/d/OfAzBjFpMDAOiH9gO9ahzpi+819/u3XSbOgcER6gAA3TabQAegMUIdAKCbBDpATwl1AIBuEegAPSfUAQC6QaADDIRQBwDIJtABBkaoAwBkEugAAyXUAQCyCHSAgRPqAAAZBDoAVSXUAQBmTaADcA6hDgAwGwIdgFUJdQCAdgl0ANYl1AEA2iHQAZiIUAcAaJZAB2BDhDoAQDMEOgCbItQBAKZLoAOwJUIdAGA6BDoAUyHUAQC2RqADMFVCHQBgcwQ6AI0Q6gAAGyPQAWiUUAcAmIxAB6AVQh0AYH0CHYBWCXUAgNUJdABmQqgDAJxLoAMwU0IdAGBMoAMQQagDAEMn0AGIItQBgKES6ABEEuoAwNAIdACiCXUAYCgEOgCdINQBgL4T6AB0ilAHAPpKoAPQSUIdAOgbgQ5Apwl1AKAvBDoAvSDUAYCuE+gA9IpQBwC6SqAD0EtCHQDoGoEOQK8JdQCgKwQ6AIMg1AGAdAIdgEER6gBAKoEOwCAJdQAgjUAHYNCEOgCQQqADQAl1AGD2BDoAnEWoAwCzItABYBVCHQBom0AHgHUIdQCgLQIdACYg1AGApgl0ANgAoQ4ANEWgA8AmCHUAYNoEOgBsgVAHAKZFoAPAFAh1AGCrBDoATJFQBwA2S6ADQAOEOgCwUQIdABok1AGASQl0AGiBUAcALkagA0CLhDoAsBaBDgAzINQBgPMJdACYIaEOAKwQ6AAQQKgDAAIdAIIIdQAYLoEOAIGEOgAMj0AHgGBCHQCGQ6ADQAcIdQDoP4EOAB0i1AGgvwQ6AHSQUAeA/hHoANBhQh0A+kOgA0APCHUA6D6BDgA9ItQBoLsEOgD0kFAHgO4R6ADQY0IdALpDoAPAAAh1AMgn0AFgQIQ6AOQS6AAwQEIdAPIIdAAYMKEOADkEOgAg1AEggEAHAD4m1AFgdgQ6AHABoQ4A7RPoAMCahDoAtEegAwAXJdQBoHkCHQCYmFAHgOYIdABgw4Q6AEyfQAcANk2oA8D0CHQAYMuEOgBsnUAHAKZGqAPA5gl0AGDqhDoAbJxABwAaI9QBYHICHQBonFAHgIsT6ABAa4Q6AKxNoAMArRPqAHAhgQ4AzIxQB4D/EOgAwMwJdQAQ6ABAEKEOwJAJdAAgjlAHYIgEOgAQS6gDMCQCHQCIJ9QBGAKBDgB0hlAHoM8EOgDQOUIdgD4S6ABAZwl1APpEoAMAnSfUAegDgQ4A9IZQB6DLBDoA0DtCHYAuEugAQG8JdQC6RKADAL0n1AHoAoEOAAyGUAcgmUAHAAZHqAOQSKADAIMl1AFIItABgMET6gAkEOgAAB8R6gDMkkAHADiPUAdgFgQ6AMAahDoAbRLoAAAXIdQBaINABwCYkFAHoEkCHQBgg4Q6AE0Q6AAAmyTUAZgmgQ4AsEVCHYBpEOgAAFMi1AHYCoEOADBlQh2AzRDoAAANEeoAbIRABwBomFAHYBICHQCgJUIdgPUIdACAlgl1AFYj0AEAZkSoA3A2gQ4AMGNCHYAqgQ4AEEOoAwybQAcACCPUAYZJoAMAhBLqAMMi0AEAwgl1gGEQ6AAAHSHUAfpNoAMAdIxQB+gngQ4A0FFCHaBfBDoAQMcJdYB+EOgAAD0h1AG6TaADAPSMUAfoJoEOANBTQh2gWwQ6AEDPCXWAbhDoAAADIdQBsgl0AICB2VSoLy5WHT1a9cMfVr3wQtXyctWBA1X33lt15EjVJZe0+A0AtuDDD6see6zqRz+qOnly/NrBg1Xf/37V7bdXbd8+s9EEOgDAQE0c6s89V3XHHVWvvVa1sFC1tDTecH5+HOp79lQ9/HDVzTe3/yUANuLYsfF/Kv797+fuz1YeX3111aOPVt1440zGE+gAAAO3XqgfeP/9uvK222rugw/+84fs+ebnxz9PPFF1yy0tTAywCceOjfdRi4tr788WFsZH0J9+uuqGG9qdrwQ6AAAfuSDUR6O6/u67a9cbb9Tc8vL6b56fr9q9u+pvf6vaubPxWQE2ZHGxau/eqn/8Y+04X7GwMD6SfurU+HGL5lv9NAAAYu3evbsOHz5c1113XV1xxRW1+9ln69LXX794nFeNT3V/++2qRx5pflCAjfrZz6refPPicV413ub118frbrRMoAMAcI6VUL/22LEabeTo0fz8eBE5gDQPPLCxo+ELC+NF5Fq2rfVPBACgE3acOjXZ0aYVy8t15sSJ+tOxY43NBLAZh48fr10b2Z8tLVW9/HJzA61BoAMAsLpN3BN9VFVnzpyZ/iwAW7Cphdc2sQ/cKoEOAMDqrr12fIu1xcWJNh/Nz9e/9+6tHTt2NDwYwMb8e//+2vnmmzU/6VH0hYWqz32u2aFWYRV3AABW9+tfV33pSxt7z0MPVX3rW83MA7BZR49W3Xrrxt7z+ONVX/96M/OsQaADALC60ajq0KGqEycmuy3Rnj1Vr75a5Qg6kGZpqerAgfHq7JPsz/btq3rppfHily2yijsAAKubmxvfNu2yy6q2rXNl5MJC1fbtVY89Js6BTAsL433UJZesv5r7wkLVzp1Vjz7aepxXCXQAANZzzTVVv/td1cGD4+dnh/rKH7mf+lTVr35VddNN7c8HMKnDh6t++9uq/fvHz88O9ZV926c/XXXs2PjsoRlwijsAABc3Go0j/P77x6e8Ly9XffazVffcM75GcyP3FwaYpeXlql/8Ynyf85Mnx69dc03VvfdWffnLM1m9fYVABwAAgABOcQcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIIBABwAAgAACHQAAAAIIdAAAAAgg0AEAACCAQAcAAIAAAh0AAAACCHQAAAAIINABAAAggEAHAACAAAIdAAAAAgh0AAAACCDQAQAAIMD/A7bYsP/AHkiRAAAAAElFTkSuQmCC" }, "metadata": {}, "output_type": "display_data" }, { "data": { - "text/plain": "" + "text/plain": [ + "" + ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "import matplotlib\n", - "from pandapipes.plotting.simple_plot import simple_plot as sp\n", - "\n", - "sp(net, plot_sinks = True)" - ] + "execution_count": 11 }, { "cell_type": "markdown", @@ -399,4 +857,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} From 34bd2450e1483c72b6d560061c03c945473d0de5 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Mon, 19 Aug 2024 20:43:37 +0200 Subject: [PATCH 220/237] added entry to CHANGELOG.rst --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4e3bcbf68..b918f17f6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,8 @@ Change Log -[CHANGED] switched from setup.py to pyproject.toml - [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" - [FIXED] Pressure plot not working for circ pump -- [ADDED] variable "u_w_per_m2k" to std_type pipe +- [FIXED] volume flow rate for incompressible fluids based on real density, thus in this case results are renamed from "vdot_norm_m3_per_s" to "vdot_m3_per_s" +- [ADDED] variable "u_w_per_m2k" to pipe std_types - [ADDED] standard district heating pipe types From 4a1cf9861756a93c29aee46458a143ef3827e555 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 20 Aug 2024 09:52:22 +0200 Subject: [PATCH 221/237] reverted unnecessary change in stanet converter --- src/pandapipes/converter/stanet/preparing_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index ec8fdbb8e..8ddde1917 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -245,7 +245,7 @@ def adapt_pipe_data_according_to_nodes(pipe_data, pipes_to_check, node_geo, pipe pipe_data.loc[pipes_to_check, pipe_name] = node_val current_pipe_data = pipe_data.loc[pipes_to_check] if not np.allclose(node_val, current_pipe_data[pipe_name].values): - wrong_data = ~np.isclose(node_val, current_pipe_data[pipe_name].values, rtol=1e-10) + wrong_data = ~np.isclose(node_val, current_pipe_data[pipe_name].values) df = pd.DataFrame( {"pipe_%s_%s" % (coord, locat): current_pipe_data[pipe_name].values[wrong_data], "node_%s_%s" % (coord, locat): node_val[wrong_data]}, index=pipe_rec[wrong_data] From cc074ed89c496d30239bea5e7e61ce6feff4c183 Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:17:41 +0200 Subject: [PATCH 222/237] github workflow for develop tests: make tutorial tests use pandapower master instead of develop (#643) --- .github/workflows/run_tests_develop.yml | 7 +++---- .github/workflows/run_tests_master.yml | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index cd2d479e8..adfa51e58 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -2,7 +2,9 @@ # A coverage report will be created for the Python 3.8 version # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -# pandapipes-develop branch is designed to work with pandapower-develop branch +# pandapipes-develop branch is designed to work with pandapower-master branch, but checks the ability to +# work with pandapower-develop branch (relying tests, usually not required for merges) in order to avoid +# problems in future releases name: ppipes_dev @@ -30,7 +32,6 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install pandapower python -m pip install . shell: bash - name: List all installed packages @@ -121,7 +122,6 @@ jobs: python -m pip install --upgrade pip python -m pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install .["all"] shell: bash - name: List all installed packages @@ -153,7 +153,6 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install .["all"] shell: bash - name: List all installed packages diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 6891298a3..8c2a1eff4 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -29,7 +29,6 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest pytest-split if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install pandapower; python -m pip install .["all"] shell: bash - name: List all installed packages From a143789691f2de310fc20c8a0718ade04ba0adc7 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Tue, 20 Aug 2024 14:20:36 +0200 Subject: [PATCH 223/237] calculate pressure drop for compressible media based on real density (not density at normal conditions); added tests for correct behavior in temperature calculation, including convergence to good fluid properties from bad starting values in bidirectional mode --- src/pandapipes/pf/derivative_calculation.py | 2 +- src/pandapipes/pf/derivative_toolbox.py | 7 +- src/pandapipes/pf/derivative_toolbox_numba.py | 6 +- .../test_pipeflow_analytic_comparison.py | 395 +++++++++++++----- 4 files changed, 309 insertions(+), 101 deletions(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 1d006c4e8..35ddda069 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -52,7 +52,7 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): as derivatives_hydraulic_incomp load_vec, load_vec_nodes, df_dm, df_dm_nodes, df_dp, df_dp1 = derivatives_hydraulic_incomp( - branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, rho, rho_n) + branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, height_difference, rho) else: if options["use_numba"]: from pandapipes.pf.derivative_toolbox_numba import derivatives_hydraulic_comp_numba \ diff --git a/src/pandapipes/pf/derivative_toolbox.py b/src/pandapipes/pf/derivative_toolbox.py index 394078198..2b7656632 100644 --- a/src/pandapipes/pf/derivative_toolbox.py +++ b/src/pandapipes/pf/derivative_toolbox.py @@ -13,13 +13,16 @@ def derivatives_hydraulic_incomp_np(branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference, rho, rho_n): + height_difference, rho): + # Formulas for pressure loss in incompressible flow + # Use medium density ((rho_from + rho_to) / 2) for Darcy Weisbach according to + # https://www.schweizer-fn.de/rohr/rohrleitung/rohrleitung.php#fluessigkeiten m_init_abs = np.abs(branch_pit[:, MDOTINIT]) m_init2 = m_init_abs * branch_pit[:, MDOTINIT] p_diff = p_init_i_abs - p_init_i1_abs const_height = rho * GRAVITATION_CONSTANT * height_difference / P_CONVERSION friction_term = np.divide(branch_pit[:, LENGTH] * branch_pit[:, LAMBDA], branch_pit[:, D]) + branch_pit[:, LC] - const_term = np.divide(1, branch_pit[:, AREA] ** 2 * rho_n * P_CONVERSION * 2) + const_term = np.divide(1, branch_pit[:, AREA] ** 2 * rho * P_CONVERSION * 2) df_dm = - const_term * (2 * m_init_abs * friction_term + der_lambda * np.divide(branch_pit[:, LENGTH], branch_pit[:, D]) * m_init2) diff --git a/src/pandapipes/pf/derivative_toolbox_numba.py b/src/pandapipes/pf/derivative_toolbox_numba.py index 6d9ba63e0..2893583f7 100644 --- a/src/pandapipes/pf/derivative_toolbox_numba.py +++ b/src/pandapipes/pf/derivative_toolbox_numba.py @@ -15,9 +15,9 @@ from numpy import int32, float64, int64 -@jit((float64[:, :], float64[:], float64[:], float64[:], float64[:], float64[:], float64[:]), nopython=True, cache=False) +@jit((float64[:, :], float64[:], float64[:], float64[:], float64[:], float64[:]), nopython=True, cache=False) def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_init_i1_abs, - height_difference, rho, rho_n): + height_difference, rho): le = der_lambda.shape[0] load_vec = np.zeros_like(der_lambda) df_dm = np.zeros_like(der_lambda) @@ -33,7 +33,7 @@ def derivatives_hydraulic_incomp_numba(branch_pit, der_lambda, p_init_i_abs, p_i const_height = rho[i] * GRAVITATION_CONSTANT * height_difference[i] / P_CONVERSION friction_term = np.divide(branch_pit[i][LENGTH] * branch_pit[i][LAMBDA], branch_pit[i][D]) \ + branch_pit[i][LC] - const_term = np.divide(1, branch_pit[i][AREA] ** 2 * rho_n[i] * P_CONVERSION * 2) + const_term = np.divide(1, branch_pit[i][AREA] ** 2 * rho[i] * P_CONVERSION * 2) df_dm[i] = -1. * const_term * (2 * m_init_abs * friction_term + der_lambda[i] * np.divide(branch_pit[i][LENGTH], branch_pit[i][D]) * m_init2) diff --git a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py index a993e0726..7e7e4149c 100644 --- a/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py +++ b/src/pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py @@ -17,6 +17,41 @@ from pandapipes.test import data_path +def create_source_2pipes_sink( + net, + t_source_k, + t_junctions_k, + mdot_kg_per_s, + length_km, + diameter_m, + pipe_name_suffix="", + k_mm=0.1, +): + j1, j2, j3 = pandapipes.create_junctions( + net, nr_junctions=3, pn_bar=1, tfluid_k=t_junctions_k + ) + pandapipes.create_pipe_from_parameters( + net, + from_junction=j1, + to_junction=j2, + name="pipe1" + pipe_name_suffix, + length_km=length_km, + diameter_m=diameter_m, + k_mm=k_mm, + ) + pandapipes.create_pipe_from_parameters( + net, + from_junction=j2, + to_junction=j3, + name="pipe2" + pipe_name_suffix, + length_km=length_km, + diameter_m=diameter_m, + k_mm=k_mm, + ) + pandapipes.create_ext_grid(net, junction=j1, p_bar=10, t_k=t_source_k) + pandapipes.create_sink(net, junction=j3, mdot_kg_per_s=mdot_kg_per_s) + + @pytest.mark.parametrize("use_numba", [True, False]) def test_gas_internal_nodes(use_numba): """ @@ -28,23 +63,42 @@ def test_gas_internal_nodes(use_numba): d = 209.1e-3 pandapipes.create_junction(net, pn_bar=51, tfluid_k=285.15) pandapipes.create_junction(net, pn_bar=51, tfluid_k=285.15) - pandapipes.create_pipe_from_parameters(net, 0, 1, 12.0, d, k_mm=.5, sections=12) + pandapipes.create_pipe_from_parameters(net, 0, 1, 12.0, d, k_mm=0.5, sections=12) pandapipes.create_ext_grid(net, 0, p_bar=51 - 1.01325, t_k=285.15, type="pt") pandapipes.create_sink(net, 1, mdot_kg_per_s=0.82752 * 45000 / 3600) - _add_fluid_to_net(net, pandapipes.create_constant_fluid( - name="natural_gas", fluid_type="gas", viscosity=11.93e-6, heat_capacity=2185, - compressibility=1, der_compressibility=0, density=0.82752 - )) + _add_fluid_to_net( + net, + pandapipes.create_constant_fluid( + name="natural_gas", + fluid_type="gas", + viscosity=11.93e-6, + heat_capacity=2185, + compressibility=1, + der_compressibility=0, + density=0.82752, + ), + ) max_iter_hyd = 6 if use_numba else 6 - pandapipes.pipeflow(net, max_iter_hyd=max_iter_hyd, - stop_condition="tol", friction_model="nikuradse", - transient=False, nonlinear_method="automatic", tol_p=1e-4, tol_m=1e-4, - use_numba=use_numba) + pandapipes.pipeflow( + net, + max_iter_hyd=max_iter_hyd, + stop_condition="tol", + friction_model="nikuradse", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) pipe_results = Pipe.get_internal_results(net, [0]) - data = pd.read_csv(os.path.join(data_path, "gas_sections_an.csv"), sep=';', header=0, - keep_default_na=False) + data = pd.read_csv( + os.path.join(data_path, "gas_sections_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) p_an = data["p1"] / 1e5 v_an = data["v"] v_an = v_an.drop([0]) @@ -85,7 +139,9 @@ def test_temperature_internal_nodes_single_pipe(use_numba): d = 75e-3 pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) - pandapipes.create_pipe_from_parameters(net, 0, 1, 6, d, k_mm=.1, sections=6, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters( + net, 0, 1, 6, d, k_mm=0.1, sections=6, u_w_per_m2k=5 + ) pandapipes.create_ext_grid(net, 0, p_bar=5, t_k=330, type="pt") pandapipes.create_sink(net, 1, mdot_kg_per_s=1) @@ -93,15 +149,28 @@ def test_temperature_internal_nodes_single_pipe(use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) pipe_results = Pipe.get_internal_results(net, [0]) - data = pd.read_csv(os.path.join(data_path, "Temperature_one_pipe_an.csv"), sep=';', - header=0, keep_default_na=False) + data = pd.read_csv( + os.path.join(data_path, "Temperature_one_pipe_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] pipe_temp_data_idx = np.where(pipe_results["TINIT"][:, 0] == 0) @@ -140,21 +209,34 @@ def test_temperature_internal_nodes_tee_2ab_1zu(use_numba): pandapipes.create_sink(net, j2, mdot_kg_per_s=1) pandapipes.create_sink(net, j3, mdot_kg_per_s=1) - pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=.1, u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=0.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=0.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=0.1, u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 4 if use_numba else 4 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), - sep=';', header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_tee_2ab_1zu_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -177,12 +259,15 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): j2 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) - pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=3, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, sections=3, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, sections=3, - u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters( + net, j0, j2, 2.5, d, k_mm=0.1, sections=3, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j1, j2, 2.5, d, k_mm=0.1, sections=3, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j2, j3, 2.5, d, k_mm=0.1, sections=3, u_w_per_m2k=5 + ) pandapipes.create_ext_grid(net, j0, p_bar=5, t_k=350, type="pt") pandapipes.create_ext_grid(net, j1, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j3, mdot_kg_per_s=1) @@ -191,13 +276,26 @@ def test_temperature_internal_nodes_tee_2zu_1ab(use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), - sep=';', header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -223,24 +321,40 @@ def test_temperature_internal_nodes_tee_2zu_1ab_direction_changed(use_numba): pandapipes.create_ext_grid(net, j1, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j3, mdot_kg_per_s=1) - pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j1, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters( + net, j0, j2, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j2, j1, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j2, j3, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 6 if use_numba else 6 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), - sep=';', header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_tee_2zu_1ab_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -268,22 +382,35 @@ def test_temperature_internal_nodes_2zu_2ab(use_numba): pandapipes.create_sink(net, j3, mdot_kg_per_s=1) pandapipes.create_sink(net, j4, mdot_kg_per_s=1) - pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=.1, u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, d, k_mm=.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=0.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=0.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j2, j3, 2.5, d, k_mm=0.1, u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters(net, j2, j4, 2.5, d, k_mm=0.1, u_w_per_m2k=5) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), sep=';', - header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_2zu_2ab_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -306,14 +433,18 @@ def test_temperature_internal_nodes_masche_1load(use_numba): j2 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) - pandapipes.create_pipe_from_parameters(net, j0, j1, 2.5, d, k_mm=.1, sections=6, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j2, 2.5, d, k_mm=.1, sections=6, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j1, j3, 2.5, d, k_mm=.1, sections=6, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j3, j2, 2.5, d, k_mm=.1, sections=6, - u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters( + net, j0, j1, 2.5, d, k_mm=0.1, sections=6, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j1, j2, 2.5, d, k_mm=0.1, sections=6, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j1, j3, 2.5, d, k_mm=0.1, sections=6, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j3, j2, 2.5, d, k_mm=0.1, sections=6, u_w_per_m2k=5 + ) pandapipes.create_ext_grid(net, j0, p_bar=5, t_k=350, type="pt") pandapipes.create_sink(net, j2, mdot_kg_per_s=1) @@ -322,13 +453,26 @@ def test_temperature_internal_nodes_masche_1load(use_numba): max_iter_hyd = 3 if use_numba else 3 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, "Temperature_masche_1load_an.csv"), - sep=';', header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_masche_1load_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -350,12 +494,15 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): j2 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=283) - pandapipes.create_pipe_from_parameters(net, j0, j2, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j0, j3, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) - pandapipes.create_pipe_from_parameters(net, j3, j2, 2.5, d, k_mm=.1, sections=5, - u_w_per_m2k=5) + pandapipes.create_pipe_from_parameters( + net, j0, j2, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j0, j3, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) + pandapipes.create_pipe_from_parameters( + net, j3, j2, 2.5, d, k_mm=0.1, sections=5, u_w_per_m2k=5 + ) pandapipes.create_fluid_from_lib(net, "water", overwrite=True) @@ -364,14 +511,26 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): max_iter_hyd = 5 if use_numba else 5 max_iter_therm = 4 if use_numba else 4 - pandapipes.pipeflow(net, stop_condition="tol", max_iter_hyd=max_iter_hyd, - max_iter_therm=max_iter_therm, friction_model="nikuradse", - mode='sequential', transient=False, nonlinear_method="automatic", tol_p=1e-4, - tol_m=1e-4, use_numba=use_numba) - - data = pd.read_csv(os.path.join(data_path, - "Temperature_masche_1load_direction_an.csv"), - sep=';', header=0, keep_default_na=False) + pandapipes.pipeflow( + net, + stop_condition="tol", + max_iter_hyd=max_iter_hyd, + max_iter_therm=max_iter_therm, + friction_model="nikuradse", + mode="sequential", + transient=False, + nonlinear_method="automatic", + tol_p=1e-4, + tol_m=1e-4, + use_numba=use_numba, + ) + + data = pd.read_csv( + os.path.join(data_path, "Temperature_masche_1load_direction_an.csv"), + sep=";", + header=0, + keep_default_na=False, + ) temp_an = data["T"] temp_pandapipes = net.res_junction["t_k"] @@ -380,5 +539,51 @@ def test_temperature_internal_nodes_masche_1load_changed_direction(use_numba): assert np.all(temp_diff < 0.01) +def test_example_hot_water(): + mdot_kg_per_s = 10 + temps_k = [300, 350] + d_pipe = 0.1 + l_pipe = 1 + + net = pandapipes.create_empty_network("network", fluid="water") + + for t_fluid in temps_k: + for t_j_k in temps_k: + create_source_2pipes_sink( + net, + t_source_k=t_fluid, + t_junctions_k=t_j_k, + pipe_name_suffix=f"_tj_{t_j_k}_tf_{t_fluid}", + mdot_kg_per_s=mdot_kg_per_s, + diameter_m=d_pipe, + length_km=l_pipe, + ) + + pandapipes.pipeflow(net, mode="bidirectional", friction_model="colebrook") + + dp = net.res_pipe.p_from_bar - net.res_pipe.p_to_bar + + # Density (for velocity calculation) is calculated at 273.15 K, which is not the same as the actual temperature of the fluid + velocities_equal = net.res_pipe["v_mean_m_per_s"].nunique() == 1 + assert not velocities_equal + rho_from_v_mean = mdot_kg_per_s / (net.res_pipe.loc[:, "v_mean_m_per_s"] * np.pi * d_pipe**2 / 4).to_numpy() + assert np.allclose(rho_from_v_mean[[0, 4]], net.fluid.get_density(temps_k)) + + # dp is really calculated from v_mean, the default density and the various lambdas + dp_calc = ( + net.res_pipe.loc[:, "lambda"] + * l_pipe + * 1000 + / d_pipe + * 0.5 + * rho_from_v_mean + * net.res_pipe.loc[:, "v_mean_m_per_s"] ** 2 + / 10**5 + ) + assert np.allclose(dp, dp_calc) + + if __name__ == "__main__": - pytest.main([r'pandapipes/test/pipflow_internals/test_pipeflow_analytic_comparison.py']) + pytest.main( + [r"pandapipes/test/pipflow_internals/test_pipeflow_analytic_comparison.py"] + ) From 6a012d9484ce16a37a60af6416b4ddc227169593 Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:25:16 +0200 Subject: [PATCH 224/237] in plotting toolbox: specify columns of geodata for which to calculate min / max in distance calculation (#645) --- src/pandapipes/plotting/plotting_toolbox.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/plotting/plotting_toolbox.py b/src/pandapipes/plotting/plotting_toolbox.py index 74ae470fa..a5f2fc981 100644 --- a/src/pandapipes/plotting/plotting_toolbox.py +++ b/src/pandapipes/plotting/plotting_toolbox.py @@ -39,8 +39,11 @@ def get_collection_sizes(net, junction_size=1.0, ext_grid_size=1.0, sink_size=1. :type heat_consumer_size: float, default 1. :return: sizes (dict) - dictionary containing all scaled sizes """ - mean_distance_between_junctions = sum((net['junction_geodata'].max() - net[ - 'junction_geodata'].min()).dropna() / 200) + mean_distance_between_junctions = sum( + (np.max(net['junction_geodata'].loc[:, ["x", "y"]].to_numpy(), axis=0) + - np.min(net['junction_geodata'].loc[:, ["x", "y"]].to_numpy(), axis=0)) + / 200 + ) sizes = { "junction": junction_size * mean_distance_between_junctions, From 6c317461ab1e57041c546622df06aa87be93aabc Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Wed, 21 Aug 2024 12:22:07 +0200 Subject: [PATCH 225/237] improvement in calculation of rho_n -> usage of np.full and filling same value instead of calculating density for same value many times based on list --- src/pandapipes/pf/derivative_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 35ddda069..314a793af 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -29,7 +29,6 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): friction_model = options["friction_model"] rho = get_branch_real_density(fluid, node_pit, branch_pit) eta = get_branch_real_eta(fluid, node_pit, branch_pit) - rho_n = fluid.get_density([NORMAL_TEMPERATURE] * len(branch_pit)) lambda_, re = calc_lambda( branch_pit[:, MDOTINIT], eta, branch_pit[:, D], @@ -63,6 +62,7 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): as derivatives_hydraulic_comp, calc_medium_pressure_with_derivative_np as \ calc_medium_pressure_with_derivative p_m, der_p_m, der_p_m1 = calc_medium_pressure_with_derivative(p_init_i_abs, p_init_i1_abs) + rho_n = np.full(fluid.get_density(NORMAL_TEMPERATURE), len(branch_pit)) comp_fact = fluid.get_compressibility(p_m) # TODO: this might not be required der_comp = fluid.get_der_compressibility() * der_p_m From 1182ab8d9714a19e765ede5fb7153051260fba50 Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Wed, 21 Aug 2024 12:34:05 +0200 Subject: [PATCH 226/237] small correction --- src/pandapipes/pf/derivative_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 314a793af..0666fc7e2 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -62,7 +62,7 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): as derivatives_hydraulic_comp, calc_medium_pressure_with_derivative_np as \ calc_medium_pressure_with_derivative p_m, der_p_m, der_p_m1 = calc_medium_pressure_with_derivative(p_init_i_abs, p_init_i1_abs) - rho_n = np.full(fluid.get_density(NORMAL_TEMPERATURE), len(branch_pit)) + rho_n = np.full(len(branch_pit), fluid.get_density(NORMAL_TEMPERATURE)) comp_fact = fluid.get_compressibility(p_m) # TODO: this might not be required der_comp = fluid.get_der_compressibility() * der_p_m From 691295f5c769b91d13d4ee92092eebe49b1ae83d Mon Sep 17 00:00:00 2001 From: dlohmeier Date: Thu, 22 Aug 2024 09:53:51 +0200 Subject: [PATCH 227/237] fixed bug of transferring a wrong lookup from active pit to pit - relevant especially for bidirectional calculation, as the pit is reused in the different runs - from_node_t and to_node_t were transferred from active_pit to pit without adaptions, although the node indices differ - now these entries were deleted from the pit and we just identify whether the flow direction must be switched for temperature calculation and get corrected from and to_node more on the fly with a helper function --- .../branch_w_internals_models.py | 4 +- .../branch_wo_internals_models.py | 4 +- .../heat_consumer_component.py | 24 +++++----- src/pandapipes/idx_branch.py | 18 ++++--- src/pandapipes/pf/build_system_matrix.py | 22 +++++---- src/pandapipes/pf/derivative_calculation.py | 18 +++---- src/pandapipes/pf/internals_toolbox.py | 47 +++++++++++++++++++ src/pandapipes/pf/pipeflow_setup.py | 6 +-- src/pandapipes/pf/result_extraction.py | 2 +- src/pandapipes/pipeflow.py | 11 +---- .../properties/properties_toolbox.py | 11 +++-- .../api/test_components/test_heat_consumer.py | 6 +-- 12 files changed, 108 insertions(+), 65 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py index de85aa611..19faae681 100644 --- a/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_w_internals_models.py @@ -7,7 +7,7 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent from pandapipes.component_models.component_toolbox import set_entry_check_repeat, vinterp, \ p_correction_height_air -from pandapipes.idx_branch import ACTIVE, FROM_NODE, FROM_NODE_T, TO_NODE, TO_NODE_T, TOUTINIT, ELEMENT_IDX, TOUTINIT +from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, ELEMENT_IDX, TOUTINIT from pandapipes.idx_node import (L, node_cols, TINIT as TINIT_NODE, HEIGHT, PINIT, PAMB, ACTIVE as ACTIVE_ND) from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number @@ -207,9 +207,7 @@ def create_pit_branch_entries(cls, net, branch_pit): branch_w_internals_pit, ACTIVE, net[cls.table_name()][cls.active_identifier()].values, internal_pipe_number, has_internals) branch_w_internals_pit[:, FROM_NODE] = from_nodes - branch_w_internals_pit[:, FROM_NODE_T] = from_nodes branch_w_internals_pit[:, TO_NODE] = to_nodes - branch_w_internals_pit[:, TO_NODE_T] = to_nodes branch_w_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] return branch_w_internals_pit, internal_pipe_number diff --git a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py index 0ce5f8e57..9af9e0df3 100644 --- a/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_wo_internals_models.py @@ -4,7 +4,7 @@ from pandapipes.component_models.abstract_models.branch_models import BranchComponent -from pandapipes.idx_branch import FROM_NODE, FROM_NODE_T, TO_NODE, TO_NODE_T, TOUTINIT, ELEMENT_IDX, ACTIVE +from pandapipes.idx_branch import FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX, ACTIVE from pandapipes.idx_node import TINIT as TINIT_NODE from pandapipes.pf.pipeflow_setup import add_table_lookup @@ -80,9 +80,7 @@ def create_pit_branch_entries(cls, net, branch_pit): = super().create_pit_branch_entries(net, branch_pit) branch_wo_internals_pit[:, ELEMENT_IDX] = net[cls.table_name()].index.values branch_wo_internals_pit[:, FROM_NODE] = from_nodes - branch_wo_internals_pit[:, FROM_NODE_T] = from_nodes branch_wo_internals_pit[:, TO_NODE] = to_nodes - branch_wo_internals_pit[:, TO_NODE_T] = to_nodes branch_wo_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE] branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values return branch_wo_internals_pit diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 6228abead..6d58a79e5 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -8,9 +8,11 @@ from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array, standard_branch_wo_internals_result_lookup) from pandapipes.component_models.junction_component import Junction -from pandapipes.idx_branch import (D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, FROM_NODE_T, JAC_DERIV_DM, JAC_DERIV_DP, - LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T) +from pandapipes.idx_branch import (D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, JAC_DERIV_DM, + JAC_DERIV_DP, LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT, + JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T) from pandapipes.idx_node import TINIT +from pandapipes.pf.internals_toolbox import get_from_nodes_corrected from pandapipes.pf.pipeflow_setup import get_lookup from pandapipes.pf.result_extraction import extract_branch_results_without_internals from pandapipes.properties.properties_toolbox import get_branch_cp @@ -112,9 +114,9 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo mask = consumer_array[:, cls.MODE] == cls.QE_DT if np.any(mask): - cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - deltat = consumer_array[:, cls.DELTAT] - mass = hc_pit[mask, QEXT] / (cp[mask] * (deltat[mask])) + cp = get_branch_cp(get_fluid(net), node_pit, hc_pit[mask]) + deltat = consumer_array[mask, cls.DELTAT] + mass = hc_pit[mask, QEXT] / (cp * deltat) hc_pit[mask, MDOTINIT] = mass @classmethod @@ -148,8 +150,8 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo mask = consumer_array[:, cls.MODE] == cls.QE_TR if np.any(mask): - cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - from_nodes = hc_pit[:, FROM_NODE_T].astype(int) + cp = get_branch_cp(get_fluid(net), node_pit, hc_pit) + from_nodes = get_from_nodes_corrected(hc_pit) t_in = node_pit[from_nodes, TINIT] t_out = hc_pit[:, TOUTINIT] @@ -166,14 +168,14 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') mask = consumer_array[:, cls.MODE] == cls.MF_DT if np.any(mask): - cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) + cp = get_branch_cp(get_fluid(net), node_pit, hc_pit) q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * consumer_array[mask, cls.DELTAT] hc_pit[mask, QEXT] = q_ext mask = consumer_array[:, cls.MODE] == cls.MF_TR if np.any(mask): - cp = get_branch_cp(net, get_fluid(net), node_pit, hc_pit) - from_nodes = hc_pit[mask, FROM_NODE_T].astype(int) + cp = get_branch_cp(get_fluid(net), node_pit, hc_pit) + from_nodes = get_from_nodes_corrected(hc_pit[mask]) t_in = node_pit[from_nodes, TINIT] t_out = hc_pit[mask, TOUTINIT] q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * (t_in - t_out) @@ -255,7 +257,7 @@ def extract_results(cls, net, options, branch_results, mode): res_table = net["res_" + cls.table_name()] res_table['qext_w'].values[:] = branch_pit[f:t, QEXT] - from_nodes = branch_pit[f:t, FROM_NODE_T].astype(int) + from_nodes = get_from_nodes_corrected(branch_pit[f:t]) t_from = node_pit[from_nodes, TINIT] tout = branch_pit[f:t, TOUTINIT] res_table['deltat_k'].values[:] = t_from - tout diff --git a/src/pandapipes/idx_branch.py b/src/pandapipes/idx_branch.py index eab984599..80eb33d80 100644 --- a/src/pandapipes/idx_branch.py +++ b/src/pandapipes/idx_branch.py @@ -31,14 +31,12 @@ LOAD_VEC_BRANCHES_T = 22 TOUTINIT = 23 # Internal slot for outlet pipe temperature JAC_DERIV_DT_NODE = 24 # Slot for the derivative fpr T for the nodes connected to branch -LOAD_VEC_NODES_T = 25 -MDOTINIT_T = 26 -FROM_NODE_T = 27 -TO_NODE_T = 28 -QEXT = 29 # heat input in [W] -TEXT = 30 -PL = 31 -TL = 32 # Temperature lift [K] -BRANCH_TYPE = 33 # branch type relevant for the pressure controller +LOAD_VEC_NODES_T = 25 # Slot for the load vector of the nodes connected to branch +FROM_NODE_T_SWITCHED = 26 # flag to indicate if the from and to node are switched in the thermal calculation +QEXT = 27 # heat input into the branch [W] +TEXT = 28 # temperature of surrounding [K] +PL = 29 # Pressure lift [bar] +TL = 30 # Temperature lift [K] +BRANCH_TYPE = 31 # branch type relevant for the pressure controller -branch_cols = 34 +branch_cols = 32 diff --git a/src/pandapipes/pf/build_system_matrix.py b/src/pandapipes/pf/build_system_matrix.py index 1ca2b272c..a6a58cf2f 100644 --- a/src/pandapipes/pf/build_system_matrix.py +++ b/src/pandapipes/pf/build_system_matrix.py @@ -3,14 +3,16 @@ # 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 scipy.sparse import csr_matrix + from pandapipes.idx_branch import FROM_NODE, TO_NODE, JAC_DERIV_DM, JAC_DERIV_DP, JAC_DERIV_DP1, \ JAC_DERIV_DM_NODE, LOAD_VEC_NODES, LOAD_VEC_BRANCHES, JAC_DERIV_DT, JAC_DERIV_DTOUT, \ - JAC_DERIV_DT_NODE, LOAD_VEC_NODES_T, LOAD_VEC_BRANCHES_T, FROM_NODE_T, TO_NODE_T, BRANCH_TYPE + JAC_DERIV_DT_NODE, LOAD_VEC_NODES_T, LOAD_VEC_BRANCHES_T, BRANCH_TYPE from pandapipes.idx_node import LOAD, TINIT from pandapipes.idx_node import P, PC, NODE_TYPE, T, NODE_TYPE_T -from pandapipes.pf.internals_toolbox import _sum_by_group_sorted, _sum_by_group +from pandapipes.pf.internals_toolbox import _sum_by_group_sorted, _sum_by_group, \ + get_from_nodes_corrected, get_to_nodes_corrected from pandapipes.pf.pipeflow_setup import get_net_option -from scipy.sparse import csr_matrix def build_system_matrix(net, branch_pit, node_pit, heat_mode): @@ -36,12 +38,16 @@ def build_system_matrix(net, branch_pit, node_pit, heat_mode): len_b = len(branch_pit) len_n = len(node_pit) branch_matrix_indices = np.arange(len_b) + len_n - fn_col, tn_col, ntyp_col, slack_type, pc_type, num_der = \ - (FROM_NODE, TO_NODE, NODE_TYPE, P, PC, 3) \ - if not heat_mode else (FROM_NODE_T, TO_NODE_T, NODE_TYPE_T, T, PC, 2) + ntyp_col, slack_type, pc_type, num_der = \ + (NODE_TYPE, P, PC, 3) if not heat_mode else (NODE_TYPE_T, T, PC, 2) pc_nodes = np.where(node_pit[:, ntyp_col] == pc_type)[0] - fn = branch_pit[:, fn_col].astype(np.int32) - tn = branch_pit[:, tn_col].astype(np.int32) + + if not heat_mode: + fn = branch_pit[:, FROM_NODE].astype(np.int32) + tn = branch_pit[:, TO_NODE].astype(np.int32) + else: + fn = get_from_nodes_corrected(branch_pit) + tn = get_to_nodes_corrected(branch_pit) not_slack_fn_branch_mask = node_pit[fn, ntyp_col] != slack_type not_slack_tn_branch_mask = node_pit[tn, ntyp_col] != slack_type pc_branch_mask = branch_pit[:, BRANCH_TYPE] == pc_type diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 1d006c4e8..c05cfed50 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -1,13 +1,15 @@ import numpy as np +from pandapipes.constants import NORMAL_TEMPERATURE from pandapipes.idx_branch import LENGTH, D, K, RE, LAMBDA, LOAD_VEC_BRANCHES, \ JAC_DERIV_DM, JAC_DERIV_DP, JAC_DERIV_DP1, LOAD_VEC_NODES, JAC_DERIV_DM_NODE, \ - FROM_NODE, TO_NODE, FROM_NODE_T, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ - LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DTOUT, JAC_DERIV_DT_NODE, MDOTINIT, MDOTINIT_T + FROM_NODE, TO_NODE, TOUTINIT, TEXT, AREA, ALPHA, TL, QEXT, LOAD_VEC_NODES_T, \ + LOAD_VEC_BRANCHES_T, JAC_DERIV_DT, JAC_DERIV_DTOUT, JAC_DERIV_DT_NODE, MDOTINIT from pandapipes.idx_node import TINIT as TINIT_NODE +from pandapipes.pf.internals_toolbox import get_from_nodes_corrected from pandapipes.properties.fluids import get_fluid -from pandapipes.constants import NORMAL_TEMPERATURE -from pandapipes.properties.properties_toolbox import get_branch_real_density, get_branch_real_eta, get_branch_cp +from pandapipes.properties.properties_toolbox import get_branch_real_density, get_branch_real_eta, \ + get_branch_cp def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): @@ -79,11 +81,11 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options): branch_pit[:, JAC_DERIV_DM_NODE] = df_dm_nodes -def calculate_derivatives_thermal(net, branch_pit, node_pit, options): +def calculate_derivatives_thermal(net, branch_pit, node_pit, _): fluid = get_fluid(net) - cp = get_branch_cp(net, fluid, node_pit, branch_pit) - m_init = branch_pit[:, MDOTINIT_T] - from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) + cp = get_branch_cp(fluid, node_pit, branch_pit) + m_init = np.abs(branch_pit[:, MDOTINIT]) + from_nodes = get_from_nodes_corrected(branch_pit) t_init_i = node_pit[from_nodes, TINIT_NODE] t_init_i1 = branch_pit[:, TOUTINIT] t_amb = branch_pit[:, TEXT] diff --git a/src/pandapipes/pf/internals_toolbox.py b/src/pandapipes/pf/internals_toolbox.py index a1e0db5f7..ddc7e3d08 100644 --- a/src/pandapipes/pf/internals_toolbox.py +++ b/src/pandapipes/pf/internals_toolbox.py @@ -4,6 +4,9 @@ import numpy as np import logging + +from pandapipes.idx_branch import FROM_NODE_T_SWITCHED, TO_NODE, FROM_NODE + try: from numba import jit numba_installed = True @@ -154,3 +157,47 @@ def _sum_values_by_index(indices, value_arr, max_ind, le, n_vals): @jit(nopython=True) def max_nb(arr): return np.max(arr) + + +def get_from_nodes_corrected(branch_pit, switch_from_to_col=None): + """ + Function to get corrected from nodes from the branch pit. + + Usually, this should be used if the velocity in a branch is negative, so that the\ + flow goes from the to_node to the from_node. The parameter switch_from_to_col indicates\ + whether the two columns shall be switched (for each row) or not. + + :param branch_pit: The branch pit + :type branch_pit: np.ndarray + :param switch_from_to_col: Indicates for each branch, whether to use the from (True) or \ + to (False) node. If None, the column FROM_NODE_T_SWITCHED is used. + :type switch_from_to_col: np.ndarray, default None + :return: + :rtype: + """ + if switch_from_to_col is None: + switch_from_to_col = branch_pit[:, FROM_NODE_T_SWITCHED] + from_node_col = switch_from_to_col.astype(np.int32) * (TO_NODE - FROM_NODE) + FROM_NODE + return branch_pit[np.arange(len(branch_pit)), from_node_col].astype(np.int32) + + +def get_to_nodes_corrected(branch_pit, switch_from_to_col=None): + """ + Function to get corrected to nodes from the branch pit. + + Usually, this should be used if the velocity in a branch is negative, so that the\ + flow goes from the to_node to the from_node. The parameter switch_from_to_col indicates\ + whether the two columns shall be switched (for each row) or not. + + :param branch_pit: The branch pit + :type branch_pit: np.ndarray + :param switch_from_to_col: Indicates for each branch, whether to use the from (False) or \ + to (True) node. If set to None, the column FROM_NODE_T_SWITCHED is used. + :type switch_from_to_col: np.ndarray, default None + :return: + :rtype: + """ + if switch_from_to_col is None: + switch_from_to_col = branch_pit[:, FROM_NODE_T_SWITCHED] + to_node_col = switch_from_to_col.astype(np.int32) * (FROM_NODE - TO_NODE) + TO_NODE + return branch_pit[np.arange(len(branch_pit)), to_node_col].astype(np.int32) diff --git a/src/pandapipes/pf/pipeflow_setup.py b/src/pandapipes/pf/pipeflow_setup.py index f6b16815e..2e3466f72 100644 --- a/src/pandapipes/pf/pipeflow_setup.py +++ b/src/pandapipes/pf/pipeflow_setup.py @@ -9,8 +9,8 @@ from pandapower.auxiliary import ppException from scipy.sparse import coo_matrix, csgraph -from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, \ - ACTIVE as ACTIVE_BR, MDOTINIT, FROM_NODE_T, TO_NODE_T +from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, MDOTINIT, \ + ACTIVE as ACTIVE_BR from pandapipes.idx_node import NODE_TYPE, P, NODE_TYPE_T, node_cols, T, ACTIVE as ACTIVE_ND, \ TABLE_IDX as TABLE_IDX_ND, ELEMENT_IDX as ELEMENT_IDX_ND from pandapipes.pf.internals_toolbox import _sum_by_group @@ -757,10 +757,8 @@ def reduce_pit(net, mode="hydraulics"): if reduced_node_lookup is not None: active_pit["branch"][:, FROM_NODE] = reduced_node_lookup[ branch_pit[branches_connected, FROM_NODE].astype(np.int32)] - active_pit["branch"][:, FROM_NODE_T] = active_pit["branch"][:, FROM_NODE] active_pit["branch"][:, TO_NODE] = reduced_node_lookup[ branch_pit[branches_connected, TO_NODE].astype(np.int32)] - active_pit["branch"][:, TO_NODE_T] = active_pit["branch"][:, TO_NODE] net["_active_pit"] = active_pit for el, connected_els in els.items(): diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 6a4b616a0..c67f71f0f 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -2,7 +2,7 @@ from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE from pandapipes.idx_branch import ELEMENT_IDX, FROM_NODE, TO_NODE, MDOTINIT, RE, \ - LAMBDA, FROM_NODE_T, TO_NODE_T, PL, TOUTINIT, AREA, TEXT + LAMBDA, PL, TOUTINIT, AREA, TEXT from pandapipes.idx_node import TABLE_IDX as TABLE_IDX_NODE, PINIT, PAMB, TINIT as TINIT_NODE from pandapipes.pf.internals_toolbox import _sum_by_group from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option diff --git a/src/pandapipes/pipeflow.py b/src/pandapipes/pipeflow.py index a2f9d0fe8..da0cd4d40 100644 --- a/src/pandapipes/pipeflow.py +++ b/src/pandapipes/pipeflow.py @@ -6,8 +6,7 @@ from numpy import linalg from scipy.sparse.linalg import spsolve -from pandapipes.idx_branch import (FROM_NODE, TO_NODE, FROM_NODE_T, TO_NODE_T, MDOTINIT, TOUTINIT, - MDOTINIT_T) +from pandapipes.idx_branch import MDOTINIT, TOUTINIT, FROM_NODE_T_SWITCHED from pandapipes.idx_node import PINIT, TINIT from pandapipes.pf.build_system_matrix import build_system_matrix from pandapipes.pf.derivative_calculation import (calculate_derivatives_hydraulic, @@ -276,13 +275,7 @@ def solve_temperature(net): # Negative velocity values are turned to positive ones (including exchange of from_node and # to_node for temperature calculation - branch_pit[:, MDOTINIT_T] = branch_pit[:, MDOTINIT] - branch_pit[:, FROM_NODE_T] = branch_pit[:, FROM_NODE] - branch_pit[:, TO_NODE_T] = branch_pit[:, TO_NODE] - mask = branch_pit[:, MDOTINIT] < 0 - branch_pit[mask, MDOTINIT_T] = -branch_pit[mask, MDOTINIT] - branch_pit[mask, FROM_NODE_T] = branch_pit[mask, TO_NODE] - branch_pit[mask, TO_NODE_T] = branch_pit[mask, FROM_NODE] + branch_pit[:, FROM_NODE_T_SWITCHED] = branch_pit[:, MDOTINIT] < 0 for comp in net['component_list']: comp.adaption_before_derivatives_thermal(net, branch_pit, node_pit, branch_lookups, options) diff --git a/src/pandapipes/properties/properties_toolbox.py b/src/pandapipes/properties/properties_toolbox.py index 2d2175a24..28eecf878 100644 --- a/src/pandapipes/properties/properties_toolbox.py +++ b/src/pandapipes/properties/properties_toolbox.py @@ -5,8 +5,9 @@ import numpy as np from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE -from pandapipes.idx_branch import TOUTINIT, FROM_NODE_T, TO_NODE +from pandapipes.idx_branch import TOUTINIT, TO_NODE from pandapipes.idx_node import TINIT, PINIT, PAMB +from pandapipes.pf.internals_toolbox import get_from_nodes_corrected def calculate_mixture_viscosity(components_viscosities, components_molar_proportions, @@ -149,7 +150,7 @@ def calculate_mass_fraction_from_molar_fraction(component_molar_proportions, com def get_branch_real_density(fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) + from_nodes = get_from_nodes_corrected(branch_pit) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] if fluid.is_gas: @@ -168,15 +169,15 @@ def get_branch_real_density(fluid, node_pit, branch_pit): return rho def get_branch_real_eta(fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) + from_nodes = get_from_nodes_corrected(branch_pit) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 eta = fluid.get_viscosity(tm) return eta -def get_branch_cp(net, fluid, node_pit, branch_pit): - from_nodes = branch_pit[:, FROM_NODE_T].astype(np.int32) +def get_branch_cp(fluid, node_pit, branch_pit): + from_nodes = get_from_nodes_corrected(branch_pit) t_from = node_pit[from_nodes, TINIT] t_to = branch_pit[:, TOUTINIT] tm = (t_from + t_to) / 2 diff --git a/src/pandapipes/test/api/test_components/test_heat_consumer.py b/src/pandapipes/test/api/test_components/test_heat_consumer.py index 1101f3d40..c5caaf304 100644 --- a/src/pandapipes/test/api/test_components/test_heat_consumer.py +++ b/src/pandapipes/test/api/test_components/test_heat_consumer.py @@ -82,7 +82,7 @@ def test_heat_consumer_equivalence2(): pandapipes.create_heat_consumer(net2, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net2, juncs[2], juncs[3], 0.1022, treturn_k=263.4459264973806, qext_w=qext[1]) - pandapipes.pipeflow(net2, mode="bidirectional", iter=25, alpha=0.5) + pandapipes.pipeflow(net2, mode="bidirectional", iter=25) pandapipes.create_heat_consumer(net3, juncs[1], juncs[4], 0.1022, controlled_mdot_kg_per_s=mdot[0], qext_w=qext[0]) pandapipes.create_heat_consumer(net3, juncs[2], juncs[3], 0.1022, deltat_k=17.82611044059695, qext_w=qext[1]) @@ -184,7 +184,7 @@ def test_heat_consumer_qext_zero(): pandapipes.create_heat_consumer(net, juncs[1], juncs[4], 0.1022, treturn_k=263.4459264973806, qext_w=0) pandapipes.create_heat_consumer(net, juncs[2], juncs[3], 0.1022, controlled_mdot_kg_per_s=1, qext_w=7500) - pandapipes.pipeflow(net, mode="bidirectional", iter=25, alpha=0.5) + pandapipes.pipeflow(net, mode="bidirectional") assert net.res_junction.at[juncs[4], 't_k'] != 263.4459264973806 @@ -204,7 +204,7 @@ def test_heat_consumer_result_extraction(): pandapipes.create_pipe_from_parameters(net, 6, 7, k_mm=0.1, length_km=1, diameter_m=0.1022, alpha_w_per_m2k=10, text_k=273.15) - pandapipes.pipeflow(net, mode="bidirectional", iter=25, alpha=0.5) + pandapipes.pipeflow(net, mode="bidirectional") #hydraulics only to check for lookup heat transfer error pandapipes.pipeflow(net) From c1e091a11fa863d9e66b15a117ab656985054abc Mon Sep 17 00:00:00 2001 From: eprade Date: Sun, 25 Aug 2024 13:59:35 +0200 Subject: [PATCH 228/237] -draft for t_outlet --- .../abstract_models/branch_models.py | 2 +- src/pandapipes/component_models/pipe_component.py | 9 +++++---- src/pandapipes/pf/result_extraction.py | 14 ++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index a486fabaa..8720c6f44 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -88,7 +88,7 @@ def create_pit_branch_entries(cls, net, branch_pit): from_nodes = junction_idx_lookup[net[cls.table_name()][fn_col].values] to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) - branch_component_pit[:, MDOTINIT] = 0.1 + branch_component_pit[:, MDOTINIT] = 1 branch_component_pit[:, TEXT] = get_net_option(net, 'ambient_temperature') return branch_component_pit, node_pit, from_nodes, to_nodes diff --git a/src/pandapipes/component_models/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 98d6232af..0dcf95ab8 100644 --- a/src/pandapipes/component_models/pipe_component.py +++ b/src/pandapipes/component_models/pipe_component.py @@ -135,6 +135,7 @@ def extract_results(cls, net, options, branch_results, mode): res_nodes_to_ht = [("t_to_k", "temp_to")] res_mean_hyd = [("vdot_norm_m3_per_s", "vf"), ("lambda", "lambda"), ("reynolds", "reynolds")] + res_branch_ht = [("t_outlet_k", "t_outlet")] if get_fluid(net).is_gas: res_nodes_from_hyd.extend([("v_from_m_per_s", "v_gas_from"), @@ -148,11 +149,11 @@ def extract_results(cls, net, options, branch_results, mode): if np.any(cls.get_internal_pipe_number(net) > 1): extract_branch_results_with_internals( net, branch_results, cls.table_name(), res_nodes_from_hyd, res_nodes_from_ht, - res_nodes_to_hyd, res_nodes_to_ht, res_mean_hyd, [], + res_nodes_to_hyd, res_nodes_to_ht, res_mean_hyd, res_branch_ht, [], cls.get_connected_node_type().table_name(), mode) else: required_results_hyd = res_nodes_from_hyd + res_nodes_to_hyd + res_mean_hyd - required_results_ht = res_nodes_from_ht + res_nodes_to_ht + required_results_ht = res_nodes_from_ht + res_nodes_to_ht + res_branch_ht extract_branch_results_without_internals( net, branch_results, required_results_hyd, required_results_ht, cls.table_name(), mode @@ -294,11 +295,11 @@ def get_result_table(cls, net): """ 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", + "t_from_k", "t_to_k", "t_outlet_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", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 6a4b616a0..a4fb5b4c7 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -28,12 +28,12 @@ def extract_all_results(net, calculation_mode): """ branch_pit = net["_pit"]["branch"] node_pit = net["_pit"]["node"] - v_mps, mf, vf, from_nodes, to_nodes, temp_from, temp_to, reynolds, _lambda, p_from, p_to, pl = \ + v_mps, mf, vf, from_nodes, to_nodes, temp_from, temp_to, t_outlet, reynolds, _lambda, p_from, p_to, pl = \ get_basic_branch_results(net, branch_pit, node_pit) branch_results = {"v_mps": v_mps, "mf_from": mf, "mf_to": -mf, "vf": vf, "p_from": p_from, "p_to": p_to, "from_nodes": from_nodes, "to_nodes": to_nodes, "temp_from": temp_from, "temp_to": temp_to, "reynolds": reynolds, - "lambda": _lambda, "pl": pl} + "lambda": _lambda, "pl": pl, "t_outlet": t_outlet} if get_fluid(net).is_gas: if get_net_option(net, "use_numba"): v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ @@ -62,7 +62,8 @@ def get_basic_branch_results(net, branch_pit, node_pit): t1 = node_pit[to_nodes, TINIT_NODE] vf = branch_pit[:, MDOTINIT] / get_fluid(net).get_density(NORMAL_TEMPERATURE) v = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] - return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, branch_pit[:, RE], \ + t_outlet = branch_pit[:, TOUTINIT] + return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, t_outlet, branch_pit[:, RE], \ branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ branch_pit[:, PL] @@ -155,7 +156,7 @@ def get_gas_vel_numba(node_pit, branch_pit, comp_from, comp_to, comp_mean, p_abs def extract_branch_results_with_internals(net, branch_results, table_name, res_nodes_from_hydraulics, res_nodes_from_heat, res_nodes_to_hydraulics, res_nodes_to_heat, - res_mean_hydraulics, res_mean_heat, node_name, + res_mean_hydraulics, res_branch_ht, res_mean_heat, node_name, simulation_mode): # the result table to write results to res_table = net["res_" + table_name] @@ -212,6 +213,11 @@ def extract_branch_results_with_internals(net, branch_results, table_name, for i, (res_name, entry) in enumerate(res_mean_hydraulics): res_table[res_name].values[pt] = res[i + 3][connected_ind] / num_internals + #outlet temperature + use_numba = get_net_option(net, "use_numba") + indices, sections = _sum_by_group(use_numba, branch_pit[:, ELEMENT_IDX], np.ones(len(branch_pit))) + indices_last_section = (np.cumsum(sections)-1).astype(int) + res_table["t_outlet_k"] = branch_results["t_outlet"][indices_last_section] def extract_branch_results_without_internals(net, branch_results, required_results_hydraulic, From a0fec557dad83f0a508642abc098843d6c5969bd Mon Sep 17 00:00:00 2001 From: eprade Date: Sun, 25 Aug 2024 14:07:15 +0200 Subject: [PATCH 229/237] -fixed change --- .../component_models/abstract_models/branch_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/component_models/abstract_models/branch_models.py b/src/pandapipes/component_models/abstract_models/branch_models.py index 8720c6f44..a486fabaa 100644 --- a/src/pandapipes/component_models/abstract_models/branch_models.py +++ b/src/pandapipes/component_models/abstract_models/branch_models.py @@ -88,7 +88,7 @@ def create_pit_branch_entries(cls, net, branch_pit): from_nodes = junction_idx_lookup[net[cls.table_name()][fn_col].values] to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values] branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1)) - branch_component_pit[:, MDOTINIT] = 1 + branch_component_pit[:, MDOTINIT] = 0.1 branch_component_pit[:, TEXT] = get_net_option(net, 'ambient_temperature') return branch_component_pit, node_pit, from_nodes, to_nodes From 671e5d3a0377c0bbd6fbab7dff1f7caf0c2efaed Mon Sep 17 00:00:00 2001 From: eprade Date: Mon, 26 Aug 2024 13:50:53 +0200 Subject: [PATCH 230/237] -fixes and added other branch components --- .../component_models/component_toolbox.py | 2 +- .../flow_control_component.py | 4 +- .../heat_consumer_component.py | 4 +- .../heat_exchanger_component.py | 4 +- .../pressure_control_component.py | 6 +-- .../component_models/pump_component.py | 6 +-- .../component_models/valve_component.py | 4 +- .../valve_pipe_component.py | 2 + src/pandapipes/pf/result_extraction.py | 48 +++++++++++-------- 9 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index b90a1fba2..fd598c5c5 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -186,7 +186,7 @@ def standard_branch_wo_internals_result_lookup(net): ("mdot_from_kg_per_s", "mf_from"), ("vdot_norm_m3_per_s", "vf"), ("lambda", "lambda"), ("reynolds", "reynolds") ] - required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] + required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to"), ("t_outlet_k", "t_outlet")] if get_fluid(net).is_gas: required_results_hyd.extend([ diff --git a/src/pandapipes/component_models/flow_control_component.py b/src/pandapipes/component_models/flow_control_component.py index fbcf909d1..033a272c3 100644 --- a/src/pandapipes/component_models/flow_control_component.py +++ b/src/pandapipes/component_models/flow_control_component.py @@ -124,11 +124,11 @@ def get_result_table(cls, net): """ 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", + "t_from_k", "t_to_k", "t_outlet_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", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index 6228abead..40f22de14 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -219,10 +219,10 @@ def get_result_table(cls, net): """ 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", + "t_to_k", "t_outlet_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", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"] output += ['deltat_k', 'qext_w'] return output, True diff --git a/src/pandapipes/component_models/heat_exchanger_component.py b/src/pandapipes/component_models/heat_exchanger_component.py index cbcaef46f..d0eeba78d 100644 --- a/src/pandapipes/component_models/heat_exchanger_component.py +++ b/src/pandapipes/component_models/heat_exchanger_component.py @@ -106,11 +106,11 @@ def get_result_table(cls, net): """ 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", + "t_from_k", "t_to_k", "t_outlet_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", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py index b2e5b3de1..4b5d32b4d 100644 --- a/src/pandapipes/component_models/pressure_control_component.py +++ b/src/pandapipes/component_models/pressure_control_component.py @@ -98,7 +98,7 @@ def extract_results(cls, net, options, branch_results, mode): ("p_from_bar", "p_from"), ("p_to_bar", "p_to"), ("mdot_from_kg_per_s", "mf_from"), ("mdot_to_kg_per_s", "mf_to"), ("vdot_norm_m3_per_s", "vf") ] - required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] + required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to"), ("t_outlet_k", "t_outlet")] if get_fluid(net).is_gas: required_results_hyd.extend([ @@ -150,10 +150,10 @@ def get_result_table(cls, net): """ if get_fluid(net).is_gas: output = ["v_from_m_per_s", "v_to_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", + "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "normfactor_from", "normfactor_to"] else: - output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s"] output += ["deltap_bar"] return output, True diff --git a/src/pandapipes/component_models/pump_component.py b/src/pandapipes/component_models/pump_component.py index eeaa8938e..aed85dfd5 100644 --- a/src/pandapipes/component_models/pump_component.py +++ b/src/pandapipes/component_models/pump_component.py @@ -140,7 +140,7 @@ def extract_results(cls, net, options, branch_results, mode): ("p_from_bar", "p_from"), ("p_to_bar", "p_to"), ("mdot_to_kg_per_s", "mf_to"), ("mdot_from_kg_per_s", "mf_from"), ("vdot_norm_m3_per_s", "vf"), ("deltap_bar", "pl"), ] - required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to")] + required_results_ht = [("t_from_k", "temp_from"), ("t_to_k", "temp_to"), ("t_outlet_k", "t_outlet")] if get_fluid(net).is_gas: required_results_hyd.extend([ @@ -219,12 +219,12 @@ def get_result_table(cls, net): output = ["deltap_bar", "v_from_m_per_s", "v_to_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", + "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "normfactor_from", "normfactor_to"] # TODO: inwieweit sind diese Angaben bei imaginärem Durchmesser sinnvoll? else: output = ["deltap_bar", "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"] + "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s"] if calc_compr_pow: output += ["compr_power_mw"] diff --git a/src/pandapipes/component_models/valve_component.py b/src/pandapipes/component_models/valve_component.py index b88403361..75a7b7bf9 100644 --- a/src/pandapipes/component_models/valve_component.py +++ b/src/pandapipes/component_models/valve_component.py @@ -86,11 +86,11 @@ def get_result_table(cls, net): """ 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", + "t_from_k", "t_to_k", "t_outlet_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", + output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "t_outlet_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"] return output, True diff --git a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py index 311a84d9f..a028cd173 100644 --- a/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py +++ b/src/pandapipes/converter/stanet/valve_pipe_component/valve_pipe_component.py @@ -93,6 +93,7 @@ def get_result_table(cls, net): "p_to_bar", "t_from_k", "t_to_k", + "t_outlet_k", "p_from_mw", "p_to_mw", "mdot_from_kg_per_s", @@ -110,6 +111,7 @@ def get_result_table(cls, net): "p_to_bar", "t_from_k", "t_to_k", + "t_outlet_k", "p_from_mw", "p_to_mw", "mdot_from_kg_per_s", diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index a4fb5b4c7..b8e3cac26 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -28,25 +28,22 @@ def extract_all_results(net, calculation_mode): """ branch_pit = net["_pit"]["branch"] node_pit = net["_pit"]["node"] - v_mps, mf, vf, from_nodes, to_nodes, temp_from, temp_to, t_outlet, reynolds, _lambda, p_from, p_to, pl = \ - get_basic_branch_results(net, branch_pit, node_pit) - branch_results = {"v_mps": v_mps, "mf_from": mf, "mf_to": -mf, "vf": vf, "p_from": p_from, - "p_to": p_to, "from_nodes": from_nodes, "to_nodes": to_nodes, - "temp_from": temp_from, "temp_to": temp_to, "reynolds": reynolds, - "lambda": _lambda, "pl": pl, "t_outlet": t_outlet} + branch_results = get_basic_branch_results(net, branch_pit, node_pit) if get_fluid(net).is_gas: if get_net_option(net, "use_numba"): v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ normfactor_to, normfactor_mean = get_branch_results_gas_numba( - net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) + net, branch_pit, node_pit, branch_results['from_nodes'], branch_results['to_nodes'], + branch_results['v_mps'], branch_results['p_from'], branch_results['p_to']) else: v_gas_from, v_gas_to, v_gas_mean, p_abs_from, p_abs_to, p_abs_mean, normfactor_from, \ normfactor_to, normfactor_mean = get_branch_results_gas( - net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to) + net, branch_pit, node_pit, branch_results['from_nodes'], branch_results['to_nodes'], + branch_results['v_mps'], branch_results['p_from'], branch_results['p_to']) gas_branch_results = { "v_gas_from": v_gas_from, "v_gas_to": v_gas_to, "v_gas_mean": v_gas_mean, - "p_from": p_from, "p_to": p_to, "p_abs_from": p_abs_from, "p_abs_to": p_abs_to, - "p_abs_mean": p_abs_mean, "normfactor_from": normfactor_from, + "p_from": branch_results['p_from'], "p_to": branch_results['p_to'], "p_abs_from": p_abs_from, + "p_abs_to": p_abs_to, "p_abs_mean": p_abs_mean, "normfactor_from": normfactor_from, "normfactor_to": normfactor_to, "normfactor_mean": normfactor_mean } branch_results.update(gas_branch_results) @@ -63,9 +60,12 @@ def get_basic_branch_results(net, branch_pit, node_pit): vf = branch_pit[:, MDOTINIT] / get_fluid(net).get_density(NORMAL_TEMPERATURE) v = branch_pit[:, MDOTINIT] / fluid.get_density(NORMAL_TEMPERATURE) / branch_pit[:, AREA] t_outlet = branch_pit[:, TOUTINIT] - return v, branch_pit[:, MDOTINIT], vf, from_nodes, to_nodes, t0, t1, t_outlet, branch_pit[:, RE], \ - branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ - branch_pit[:, PL] + branch_results = {"v_mps": v, "mf_from": branch_pit[:, MDOTINIT], "mf_to": -branch_pit[:, MDOTINIT], + "vf": vf, "p_from": node_pit[from_nodes, PINIT], "p_to": node_pit[to_nodes, PINIT], + "from_nodes": from_nodes, "to_nodes": to_nodes, "temp_from": t0, "temp_to": t1, + "reynolds": branch_pit[:, RE], "lambda": branch_pit[:, LAMBDA], "pl": branch_pit[:, PL], + "t_outlet": t_outlet} + return branch_results def get_branch_results_gas(net, branch_pit, node_pit, from_nodes, to_nodes, v_mps, p_from, p_to): @@ -176,9 +176,9 @@ def extract_branch_results_with_internals(net, branch_results, table_name, # the id of the external node table inside the node_pit (mostly this is "junction": 0) ext_node_tbl_idx = get_table_number(get_lookup(net, "node", "table"), node_name) - for (result_mode, res_nodes_from, res_nodes_to, res_mean) in [ - ("hydraulics", res_nodes_from_hydraulics, res_nodes_to_hydraulics, res_mean_hydraulics), - ("heat", res_nodes_from_heat, res_nodes_to_heat, res_mean_heat) + for (result_mode, res_nodes_from, res_nodes_to, res_mean, res_branch) in [ + ("hydraulics", res_nodes_from_hydraulics, res_nodes_to_hydraulics, res_mean_hydraulics, []), + ("heat", res_nodes_from_heat, res_nodes_to_heat, res_mean_heat, res_branch_ht) ]: if result_mode == "hydraulics" and simulation_mode == "heat": continue @@ -213,11 +213,17 @@ def extract_branch_results_with_internals(net, branch_results, table_name, for i, (res_name, entry) in enumerate(res_mean_hydraulics): res_table[res_name].values[pt] = res[i + 3][connected_ind] / num_internals - #outlet temperature - use_numba = get_net_option(net, "use_numba") - indices, sections = _sum_by_group(use_numba, branch_pit[:, ELEMENT_IDX], np.ones(len(branch_pit))) - indices_last_section = (np.cumsum(sections)-1).astype(int) - res_table["t_outlet_k"] = branch_results["t_outlet"][indices_last_section] + if len(res_branch) > 0: + use_numba = get_net_option(net, "use_numba") + indices, sections, connected_sum = _sum_by_group(use_numba, idx_pit, np.ones_like(idx_pit), + comp_connected.astype(np.int32)) + connected_ind = connected_sum > 0.99 + indices_last_section = (np.cumsum(sections) - 1).astype(int)[connected_ind] + # hint: idx_pit[placement_table] should result in the indices as ordered in the table + pt = placement_table[connected_ind] + + for i, (res_name, entry) in enumerate(res_branch): + res_table[res_name].values[pt] = branch_results[entry][indices_last_section] def extract_branch_results_without_internals(net, branch_results, required_results_hydraulic, From cc296ac19c68ed41511a978a4ce8e6bee894b77f Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 27 Aug 2024 09:29:12 +0200 Subject: [PATCH 231/237] -small change and changelog --- CHANGELOG.rst | 2 +- src/pandapipes/pf/result_extraction.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4e3bcbf68..11121ff36 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,7 +8,7 @@ Change Log - [FIXED] Pressure plot not working for circ pump - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types - +- [ADDED] t_outlet_k to result tables of branch components [0.10.0] - 2024-04-09 diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index b8e3cac26..4857f5b1b 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -215,7 +215,7 @@ def extract_branch_results_with_internals(net, branch_results, table_name, res_table[res_name].values[pt] = res[i + 3][connected_ind] / num_internals if len(res_branch) > 0: use_numba = get_net_option(net, "use_numba") - indices, sections, connected_sum = _sum_by_group(use_numba, idx_pit, np.ones_like(idx_pit), + _, sections, connected_sum = _sum_by_group(use_numba, idx_pit, np.ones_like(idx_pit), comp_connected.astype(np.int32)) connected_ind = connected_sum > 0.99 indices_last_section = (np.cumsum(sections) - 1).astype(int)[connected_ind] From aac49d6aa195b314d8ae2d6f800e0b381af65f02 Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:41:54 +0200 Subject: [PATCH 232/237] Chore: EOL of python v 3.8 (#644) * chore: removed python 3.8 from pyproject.toml and from all python versions in workflow matrix * added changelog entry * upgraded versions for testing and added numba - added numba to the test / all dependencies - all tests are now run with the ["all"] installation - all additional tests (tutorials, codecov, without numba) are run on python 3.11 - for python 3.12, add setuptools as test dependency, as it is not included in the standard library any more - cleanup in workflows: no requirements.txt, do not install packages included in ["all"] scheme --- .github/workflows/release.yml | 2 +- .github/workflows/run_tests_develop.yml | 52 ++++++++++++------------- .github/workflows/run_tests_master.yml | 43 ++++++++++---------- CHANGELOG.rst | 10 +++-- pyproject.toml | 15 ++++--- src/pandapipes/test/test_imports.py | 7 +++- 6 files changed, 68 insertions(+), 61 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 423f571a2..c6b46c38b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: needs: upload strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index adfa51e58..cbe5ea65a 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -1,5 +1,5 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# A coverage report will be created for the Python 3.8 version +# A coverage report will be created for the Python 3.9 version # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions # pandapipes-develop branch is designed to work with pandapower-master branch, but checks the ability to @@ -19,7 +19,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -30,24 +30,27 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python -m pip install . + python -m pip install .["all"] shell: bash - name: List all installed packages run: | python -m pip list - name: Test with pytest - if: ${{ matrix.python-version != '3.9' }} + if: ${{ matrix.python-version != '3.11' }} run: | python -m pytest + - name: Test without numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip uninstall numba -y + python -m pytest -n=auto - name: Test with pytest and Codecov - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install pytest-cov python -m pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} uses: codecov/codecov-action@v1 with: verbose: true @@ -56,7 +59,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -67,8 +70,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest igraph pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower python -m pip install .["all"] shell: bash @@ -76,21 +77,16 @@ jobs: run: | python -m pip list - name: Test with pytest - if: ${{ matrix.python-version != '3.9' }} + if: ${{ matrix.python-version != '3.11' }} run: | python -m pytest - - name: Test with numba - if: ${{ matrix.python-version == '3.11' }} - run: | - python -m pip install numba - python -m pytest -n=auto - name: Test with pytest and Codecov - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install pytest-cov python -m pytest -n=auto --cov=./ --cov-report=xml - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} uses: codecov/codecov-action@v4 with: verbose: true @@ -104,12 +100,17 @@ jobs: 'pandapipes/networks/network_files/**' '**.yml' '**.rst' + - name: Test without numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip uninstall numba -y + python -m pytest -n=auto linting: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.10'] + python-version: ['3.11'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -121,7 +122,6 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install flake8 - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install .["all"] shell: bash - name: List all installed packages @@ -140,7 +140,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -151,8 +151,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install .["all"] shell: bash - name: List all installed packages @@ -161,17 +159,17 @@ jobs: - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" - - name: Test with numba + - name: Test without numba if: ${{ matrix.python-version == '3.11' }} run: | - python -m pip install numba + python -m pip uninstall numba -y python -m pytest --nbmake -n=auto "./tutorials" docs_check: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.10' ] + python-version: [ '3.11' ] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index 8c2a1eff4..d3be4c29d 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -27,36 +27,29 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install .["all"] shell: bash - name: List all installed packages run: | python -m pip list - name: Test with pytest - if: ${{ matrix.python-version != '3.9' }} + if: ${{ matrix.python-version != '3.11' }} run: | python -m pytest - - name: Test with numba - if: ${{ matrix.python-version == '3.11' }} - run: | - python -m pip install numba - python -m pytest -n=auto - name: Test with pytest, Codecov and Coverage - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} run: | python -m pip install pytest-cov python -m pytest --nbmake -n=auto --cov=./ --cov-report=xml cp ./coverage.xml ./codecov_coverage.xml - name: Upload coverage to Codacy - if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}} + if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'}} env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} run: | bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.xml - name: Upload coverage to Codecov - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -70,13 +63,18 @@ jobs: 'pandapipes/networks/network_files/**' '**.yml' '**.rst' + - name: Test without numba + if: ${{ matrix.python-version == '3.11' }} + run: | + python -m pip uninstall numba -y + python -m pytest -n=auto relying: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -87,23 +85,26 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install .["all"] shell: bash - name: List all installed packages run: | python -m pip list - name: Test with pytest - if: ${{ matrix.python-version != '3.9' }} + # if: ${{ matrix.python-version != '3.11' }} + run: | + python -m pytest -n=auto + - name: Test without numba + if: ${{ matrix.python-version == '3.11' }} run: | + python -m pip uninstall numba -y python -m pytest -n=auto tutorial_tests: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 @@ -114,8 +115,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest==8.0.2 nbmake pytest-xdist pytest-split - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install .["all"] shell: bash - name: List all installed packages @@ -124,10 +123,10 @@ jobs: - name: Test with pytest run: | python -m pytest --nbmake -n=auto "./tutorials" - - name: Test with numba + - name: Test without numba if: ${{ matrix.python-version == '3.11' }} run: | - python -m pip install numba + python -m pip uninstall numba -y python -m pytest --nbmake -n=auto "./tutorials" @@ -135,7 +134,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.10' ] + python-version: [ '3.11' ] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4e3bcbf68..752e62fad 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,12 +2,14 @@ Change Log ============= --[ADDED] heat_consumer plotting --[CHANGED] switched from setup.py to pyproject.toml -- [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" -- [FIXED] Pressure plot not working for circ pump +- [ADDED] heat_consumer plotting - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types +- [ADDED] support for Python 3.12 +- [CHANGED] switched from setup.py to pyproject.toml +- [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" +- [FIXED] Pressure plot not working for circ pump +- [REMOVED] support for Python 3.8 due to EOL diff --git a/pyproject.toml b/pyproject.toml index b9a698c75..500fc2d93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors=[ description = "A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids" readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", @@ -26,7 +26,6 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", # Add the specific Python versions supported here, e.g.: - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -38,7 +37,8 @@ dependencies = [ "shapely", ] keywords = [ - "network", "analysis", "optimization", "automation", "grid", "energy", "engineering", "simulation", "pipeflow", "pandapipes", "gas" + "network", "analysis", "optimization", "automation", "grid", "energy", "engineering", + "simulation", "pipeflow", "pandapipes", "gas" ] [project.urls] @@ -53,11 +53,14 @@ Changelog = "https://github.com/e2nIEE/pandapipes/blob/develop/CHANGELOG.rst" [project.optional-dependencies] docs = ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "sphinx-pyproject"] plotting = ["plotly", "igraph"] -test = ["pytest", "pytest-xdist", "nbmake"] +test = [ + "pytest", "pytest-xdist", "pytest-split", "nbmake", "numba", + "setuptools; python_version >= '3.12'" +] all = [ "numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", - "plotly", "igraph", - "pytest", "pytest-xdist", "nbmake" + "plotly", "igraph", "pytest", "pytest-xdist", "pytest-split", "nbmake", "numba", + "setuptools; python_version >= '3.12'" ] [tool.setuptools.packages.find] diff --git a/src/pandapipes/test/test_imports.py b/src/pandapipes/test/test_imports.py index ce19339d8..1a78a01d5 100644 --- a/src/pandapipes/test/test_imports.py +++ b/src/pandapipes/test/test_imports.py @@ -8,9 +8,14 @@ import pytest from pandapipes import pp_dir -from setuptools import find_packages +try: + from setuptools import find_packages + SETUPTOOLS_AVAILABLE = True +except ImportError: + SETUPTOOLS_AVAILABLE = False +@pytest.mark.skipif(not SETUPTOOLS_AVAILABLE, reason="setuptools not available") def test_import_packages(): all_packages = find_packages(pp_dir) for pck in all_packages: From 9f0eb54ce06653f9bfe0d3222b4e7f4908ae016f Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 27 Aug 2024 10:50:40 +0200 Subject: [PATCH 233/237] -log conflict --- CHANGELOG.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 11121ff36..16d2932c1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,13 +2,16 @@ Change Log ============= --[ADDED] heat_consumer plotting --[CHANGED] switched from setup.py to pyproject.toml -- [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" -- [FIXED] Pressure plot not working for circ pump +- [ADDED] heat_consumer plotting - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types +- [ADDED] support for Python 3.12 - [ADDED] t_outlet_k to result tables of branch components +- [CHANGED] switched from setup.py to pyproject.toml +- [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" +- [FIXED] Pressure plot not working for circ pump +- [REMOVED] support for Python 3.8 due to EOL + [0.10.0] - 2024-04-09 From f215fb3cff60e34e0278a49164dd9f338199e562 Mon Sep 17 00:00:00 2001 From: eprade Date: Tue, 27 Aug 2024 10:53:52 +0200 Subject: [PATCH 234/237] -conflict fix --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 752e62fad..16d2932c1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Change Log - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types - [ADDED] support for Python 3.12 +- [ADDED] t_outlet_k to result tables of branch components - [CHANGED] switched from setup.py to pyproject.toml - [CHANGED] variable "alpha_w_per_m2k" to "u_w_per_m2k" - [FIXED] Pressure plot not working for circ pump From 1cd36e98ceb359f5c0e4337adcbcbae3f9aad808 Mon Sep 17 00:00:00 2001 From: V3 Date: Thu, 19 Sep 2024 22:26:48 +0200 Subject: [PATCH 235/237] fixed some imports from pandapower. (#650) --- CHANGELOG.rst | 2 +- src/pandapipes/io/file_io.py | 2 +- src/pandapipes/multinet/control/run_control_multinet.py | 4 ++-- src/pandapipes/multinet/multinet.py | 3 +-- src/pandapipes/toolbox.py | 4 +++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d94805361..5c48ad72e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change Log ============= - +- [FIXED] some imports from pandapower - [ADDED] heat_consumer plotting - [ADDED] variable "u_w_per_m2k" to std_type pipe - [ADDED] standard district heating pipe types diff --git a/src/pandapipes/io/file_io.py b/src/pandapipes/io/file_io.py index d50b59f10..15766b03b 100644 --- a/src/pandapipes/io/file_io.py +++ b/src/pandapipes/io/file_io.py @@ -15,7 +15,7 @@ from pandapipes.io.io_utils import isinstance_partial, FromSerializableRegistryPpipe from pandapipes.pandapipes_net import pandapipesNet from pandapipes.multinet import MultiNet -from pandapower import pandapowerNet +from pandapower.auxiliary import pandapowerNet from pandapower.convert_format import convert_format as convert_format_pandapower diff --git a/src/pandapipes/multinet/control/run_control_multinet.py b/src/pandapipes/multinet/control/run_control_multinet.py index a68c94c21..1d69ed775 100644 --- a/src/pandapipes/multinet/control/run_control_multinet.py +++ b/src/pandapipes/multinet/control/run_control_multinet.py @@ -6,7 +6,7 @@ import pandas as pd import pandapipes as ppipes -import pandapower as pp +from pandapower.auxiliary import pandapowerNet from pandapipes.control.run_control import prepare_run_ctrl as prepare_run_ctrl_ppipes from pandapower.control.run_control import prepare_run_ctrl as prepare_run_ctrl_pp, \ net_initialization, get_recycle, control_initialization, control_finalization, \ @@ -219,7 +219,7 @@ def prepare_ctrl_variables_for_net(multinet, net_name, ctrl_variables, **kwargs) net = multinet['nets'][net_name] if isinstance(net, ppipes.pandapipesNet): ctrl_variables_net = prepare_run_ctrl_ppipes(net, None, **kwargs) - elif isinstance(net, pp.pandapowerNet): + elif isinstance(net, pandapowerNet): ctrl_variables_net = prepare_run_ctrl_pp(net, None, **kwargs) else: raise ValueError('the given nets are neither pandapipes nor pandapower nets') diff --git a/src/pandapipes/multinet/multinet.py b/src/pandapipes/multinet/multinet.py index 6468bb5f6..cc50fa448 100644 --- a/src/pandapipes/multinet/multinet.py +++ b/src/pandapipes/multinet/multinet.py @@ -6,8 +6,7 @@ import pandas as pd from numpy import dtype -from pandapower import pandapowerNet -from pandapower.auxiliary import ADict +from pandapower.auxiliary import ADict, pandapowerNet from pandapipes import __version__ from pandapipes import pandapipesNet diff --git a/src/pandapipes/toolbox.py b/src/pandapipes/toolbox.py index e70a4bf71..b38508945 100644 --- a/src/pandapipes/toolbox.py +++ b/src/pandapipes/toolbox.py @@ -8,7 +8,9 @@ import numpy as np import pandas as pd from networkx import has_path -from pandapower import get_indices, dataframes_equal, clear_result_tables +from pandapower.auxiliary import get_indices +from pandapower.toolbox import dataframes_equal +from pandapower.toolbox.result_info import clear_result_tables import pandapipes from pandapipes.component_models.abstract_models.branch_models import BranchComponent From 48b76b2f8ab7a048fd57f4bfcd59ece34fe9a47b Mon Sep 17 00:00:00 2001 From: Daniel Lohmeier <31214121+dlohmeier@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:06:25 +0200 Subject: [PATCH 236/237] the return temperature of the heat consumer is not fixed for the solver anymore, but calculated based on an exact estimate of qext from inlet and controlled return temperature (#652) --- src/pandapipes/component_models/heat_consumer_component.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pandapipes/component_models/heat_consumer_component.py b/src/pandapipes/component_models/heat_consumer_component.py index c7d1d31f3..d3f574efa 100644 --- a/src/pandapipes/component_models/heat_consumer_component.py +++ b/src/pandapipes/component_models/heat_consumer_component.py @@ -91,6 +91,9 @@ def create_component_array(cls, net, component_pits): tbl = net[cls.table_name()] consumer_array = np.zeros(shape=(len(tbl), cls.internal_cols), dtype=np.float64) consumer_array[:, cls.DELTAT] = tbl.deltat_k.values + consumer_array[:, cls.TRETURN] = tbl.treturn_k.values + consumer_array[:, cls.QEXT] = tbl.qext_w.values + consumer_array[:, cls.MASS] = tbl.controlled_mdot_kg_per_s.values mf = tbl.controlled_mdot_kg_per_s.values tr = tbl.treturn_k.values dt = tbl.deltat_k.values @@ -177,7 +180,7 @@ def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_look cp = get_branch_cp(get_fluid(net), node_pit, hc_pit) from_nodes = get_from_nodes_corrected(hc_pit[mask]) t_in = node_pit[from_nodes, TINIT] - t_out = hc_pit[mask, TOUTINIT] + t_out = consumer_array[mask, cls.TRETURN] q_ext = cp[mask] * hc_pit[mask, MDOTINIT] * (t_in - t_out) hc_pit[mask, QEXT] = q_ext @@ -188,7 +191,7 @@ def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_looku consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer') # Any MODE where TRETURN is given - mask = np.isin(consumer_array[:, cls.MODE], [cls.MF_TR, cls.QE_TR]) + mask = consumer_array[:, cls.MODE] == cls.QE_TR if np.any(mask): hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0 hc_pit[mask, JAC_DERIV_DTOUT] = 1 From 992dfed270f905a6dbb2945b0a401e1e42162820 Mon Sep 17 00:00:00 2001 From: Moritz Franz Date: Mon, 21 Oct 2024 15:13:03 +0200 Subject: [PATCH 237/237] some fixes for numpy 2.0 --- src/pandapipes/component_models/component_toolbox.py | 2 +- src/pandapipes/pf/result_extraction.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index a12cc1a0d..4ba1324d4 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -84,7 +84,7 @@ def init_results_element(net, element, output, all_float): """ res_element = "res_" + element if all_float: - net[res_element] = pd.DataFrame(np.NAN, columns=output, index=net[element].index, + net[res_element] = pd.DataFrame(np.nan, columns=output, index=net[element].index, dtype=np.float64) else: net[res_element] = pd.DataFrame(np.zeros(0, dtype=output), index=[]) diff --git a/src/pandapipes/pf/result_extraction.py b/src/pandapipes/pf/result_extraction.py index 0b674d311..19e6faf06 100644 --- a/src/pandapipes/pf/result_extraction.py +++ b/src/pandapipes/pf/result_extraction.py @@ -308,10 +308,10 @@ def extract_results_active_pit(net, mode="hydraulics"): amb = get_net_option(net, 'ambient_temperature') - net["_pit"]["node"][~nodes_connected, result_node_col] = np.NaN if mode == "hydraulics" else amb + net["_pit"]["node"][~nodes_connected, result_node_col] = np.nan if mode == "hydraulics" else amb net["_pit"]["node"][rows_nodes[:, np.newaxis], copied_node_cols[np.newaxis, :]] = \ net["_active_pit"]["node"][:, copied_node_cols] - net["_pit"]["branch"][~branches_connected, result_branch_col] = np.NaN if mode == "hydraulics" else \ + net["_pit"]["branch"][~branches_connected, result_branch_col] = np.nan if mode == "hydraulics" else \ net["_pit"]["branch"][~branches_connected, TEXT] net["_pit"]["branch"][rows_branches[:, np.newaxis], copied_branch_cols[np.newaxis, :]] = \ net["_active_pit"]["branch"][:, copied_branch_cols]