diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3e79f9eb2..fe838e15a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,9 @@ Change Log ============= +[0.10.1] - +------------------------------- +- [CHANGED] circ_pump_pressure to now have the option to chose a "setpoint" (flow or return junction) for the pressure to be set at + [0.10.0] - 2024-04-09 ------------------------------- 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 diff --git a/src/pandapipes/component_models/abstract_models/circulation_pump.py b/src/pandapipes/component_models/abstract_models/circulation_pump.py index c678b44a2..118aae173 100644 --- a/src/pandapipes/component_models/abstract_models/circulation_pump.py +++ b/src/pandapipes/component_models/abstract_models/circulation_pump.py @@ -7,7 +7,7 @@ from pandapipes.component_models.abstract_models.branch_wzerolength_models import \ BranchWZeroLengthComponent from pandapipes.component_models.component_toolbox import set_fixed_node_entries, \ - get_mass_flow_at_nodes + get_mass_flow_at_nodes, set_fixed_node_entries_circ_pump from pandapipes.idx_branch import D, AREA, ACTIVE from pandapipes.idx_node import PINIT from pandapipes.pf.pipeflow_setup import get_lookup @@ -68,12 +68,21 @@ 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 = circ_pump_tbl[cls.from_to_node_cols()[1]].values + flow_junction = circ_pump_tbl[cls.from_to_node_cols()[1]].values + junctions = np.zeros(len(circ_pump_tbl),dtype=np.int8) + flow_col = cls.from_to_node_cols()[1] + return_col = cls.from_to_node_cols()[0] + + flow_mask = circ_pump_tbl["setpoint"] == "flow" + return_mask = circ_pump_tbl["setpoint"] == "return" + + junctions[flow_mask] = circ_pump_tbl[flow_col][flow_mask] + junctions[return_mask] = circ_pump_tbl[return_col][return_mask] # 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 - press = circ_pump_tbl.p_flow_bar.values - set_fixed_node_entries(net, node_pit, junction, circ_pump_tbl.type.values, press, + press = circ_pump_tbl.p_setpoint_bar.values + set_fixed_node_entries_circ_pump(net, node_pit, junctions, flow_junction, circ_pump_tbl.type.values, press, circ_pump_tbl.t_flow_k.values, cls.get_connected_node_type()) return circ_pump_tbl, press diff --git a/src/pandapipes/component_models/circulation_pump_mass_component.py b/src/pandapipes/component_models/circulation_pump_mass_component.py index 39cdb217b..d67f20fea 100644 --- a/src/pandapipes/component_models/circulation_pump_mass_component.py +++ b/src/pandapipes/component_models/circulation_pump_mass_component.py @@ -36,8 +36,9 @@ def get_component_input(cls): return [("name", dtype(object)), ("return_junction", "u4"), ("flow_junction", "u4"), - ("p_flow_bar", "f8"), + ("p_setpoint_bar", "f8"), ("t_flow_k", "f8"), + ("setpoint", "str"), ("mdot_flow_kg_per_s", "f8"), ("in_service", 'bool'), ("type", dtype(object))] diff --git a/src/pandapipes/component_models/circulation_pump_pressure_component.py b/src/pandapipes/component_models/circulation_pump_pressure_component.py index fb7ff2af3..07054e485 100644 --- a/src/pandapipes/component_models/circulation_pump_pressure_component.py +++ b/src/pandapipes/component_models/circulation_pump_pressure_component.py @@ -1,11 +1,11 @@ # 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 from numpy import dtype from pandapipes.component_models.abstract_models.circulation_pump import CirculationPump -from pandapipes.component_models.component_toolbox import set_fixed_node_entries +from pandapipes.component_models.component_toolbox import set_fixed_node_entries_circ_pump from pandapipes.component_models.junction_component import Junction try: @@ -32,9 +32,10 @@ def get_component_input(cls): return [("name", dtype(object)), ("return_junction", "u4"), ("flow_junction", "u4"), - ("p_flow_bar", "f8"), + ("p_setpoint_bar", "f8"), ("t_flow_k", "f8"), ("plift_bar", "f8"), + ("setpoint","str"), ("in_service", 'bool'), ("type", dtype(object))] @@ -58,8 +59,23 @@ def create_pit_node_entries(cls, net, node_pit): :return: No Output. """ circ_pump, press = super().create_pit_node_entries(net, node_pit) + flow_junction = circ_pump[cls.from_to_node_cols()[1]].values + junctions = numpy.zeros(len(circ_pump), dtype=numpy.int8) + p_setpoint = numpy.zeros(len(circ_pump), dtype=float) + + flow_col = cls.from_to_node_cols()[0] + return_col = cls.from_to_node_cols()[1] + + flow_mask = circ_pump["setpoint"] == "flow" + return_mask = circ_pump["setpoint"] == "return" + + junctions[flow_mask] = circ_pump[flow_col][flow_mask] + junctions[return_mask] = circ_pump[return_col][return_mask] + + p_setpoint[flow_mask] = press[flow_mask] - circ_pump.plift_bar.values[flow_mask] + p_setpoint[return_mask] = press[return_mask] + circ_pump.plift_bar.values[return_mask] + + set_fixed_node_entries_circ_pump(net, node_pit, junctions, flow_junction, circ_pump.type.values, + p_setpoint, None, + cls.get_connected_node_type(), "p") - junction = circ_pump[cls.from_to_node_cols()[0]].values - p_in = press - circ_pump.plift_bar.values - set_fixed_node_entries(net, node_pit, junction, circ_pump.type.values, p_in, None, - cls.get_connected_node_type(), "p") diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index 840929bc4..bb6d1a5b9 100644 --- a/src/pandapipes/component_models/component_toolbox.py +++ b/src/pandapipes/component_models/component_toolbox.py @@ -148,6 +148,34 @@ def set_fixed_node_entries(net, node_pit, junctions, eg_types, p_values, t_value else: val_col, type_col, eg_count_col, typ, valid_types, values = \ TINIT, NODE_TYPE_T, EXT_GRID_OCCURENCE_T, T, ["t", "pt"], t_values + + mask = np.isin(eg_types, valid_types) + if not np.any(mask): + continue + use_numba = get_net_option(net, "use_numba") + juncts, press_sum, number = _sum_by_group(use_numba, junctions[mask], values[mask], + np.ones_like(values[mask], dtype=np.int32)) + index = junction_idx_lookups[juncts] + node_pit[index, val_col] = (node_pit[index, val_col] * node_pit[index, eg_count_col] + + press_sum) / (number + node_pit[index, eg_count_col]) + node_pit[index, type_col] = typ + node_pit[index, eg_count_col] += number + + +def set_fixed_node_entries_circ_pump(net, node_pit, junctions, flow_junctions, eg_types, p_values, t_values, node_comp, + mode="all"): + #added so that in case of setpoint for pressure at return junction can be set while setting temperature at flow junction + 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": + continue + if eg_type == "p": + val_col, type_col, eg_count_col, typ, valid_types, values = \ + PINIT, NODE_TYPE, EXT_GRID_OCCURENCE, P, ["p", "pt"], p_values + else: + val_col, type_col, eg_count_col, typ, valid_types, values = \ + TINIT, NODE_TYPE_T, EXT_GRID_OCCURENCE_T, T, ["t", "pt"], t_values + junctions = flow_junctions mask = np.isin(eg_types, valid_types) if not np.any(mask): continue diff --git a/src/pandapipes/create.py b/src/pandapipes/create.py index f7dc2651f..8ae686b92 100644 --- a/src/pandapipes/create.py +++ b/src/pandapipes/create.py @@ -21,6 +21,7 @@ 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 +import warnings try: import pandaplan.core.pplog as logging @@ -702,9 +703,26 @@ def create_pump_from_parameters(net, from_junction, to_junction, new_std_type_na 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 handle_deprecated_args_circ_pump(func): + def wrapper(*args, **kwargs): + + if 'p_setpoint_bar' not in kwargs and 'p_flow_bar' in kwargs: + + kwargs['p_setpoint_bar'] = kwargs.pop('p_flow_bar') + warnings.warn( + "The 'p_flow_bar' argument is deprecated and will be removed in a future version. " + "Please use 'p_setpoint_bar' instead.", + DeprecationWarning + ) + + return func(*args, **kwargs) + + return wrapper + +@handle_deprecated_args_circ_pump +def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_setpoint_bar, plift_bar, + t_flow_k=None, setpoint="flow", 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 @@ -720,12 +738,14 @@ def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_ :type return_junction: int :param flow_junction: ID of the junction on the other side which the pump will be connected with :type flow_junction: int - :param p_flow_bar: Pressure set point at the flow junction - :type p_flow_bar: float + :param p_setpoint_bar: Pressure set point at the set junction + :type p_setpoint_bar: float :param plift_bar: Pressure lift induced by the pump :type plift_bar: float :param t_flow_k: Temperature set point at the flow junction :type t_flow_k: float, default None + :param setpoint: set point for the pressure; either "flow" or "return" junction + :type setpoint: string, default "flow" :param type: The pump type denotes the values that are fixed:\n - "auto": Will automatically assign one of the following types based on the input for \ p_bar and t_k \n @@ -749,11 +769,10 @@ def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_ :rtype: int :Example: - >>> create_circ_pump_const_pressure(net, 0, 1, p_flow_bar=5, plift_bar=2, + >>> create_circ_pump_const_pressure(net, 0, 1, p_setpoint_bar=5, plift_bar=2, >>> t_flow_k=350, type="p") """ - add_new_component(net, CirculationPumpPressure) index = _get_index_with_check(net, "circ_pump_pressure", index, @@ -761,17 +780,17 @@ def create_circ_pump_const_pressure(net, return_junction, flow_junction, p_flow_ _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) + type = _auto_ext_grid_type(p_setpoint_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, + "p_setpoint_bar": p_setpoint_bar, "t_flow_k": t_flow_k, "plift_bar": plift_bar , "setpoint":setpoint,"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, +@handle_deprecated_args_circ_pump +def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_setpoint_bar, mdot_flow_kg_per_s, t_flow_k=None, type="auto", name=None, index=None, in_service=True, **kwargs): """ @@ -789,8 +808,8 @@ def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_flow :type return_junction: int :param flow_junction: ID of the junction on the other side which the pump will be connected with :type flow_junction: int - :param p_flow_bar: Pressure set point at the flow junction - :type p_flow_bar: float + :param p_setpoint_bar: Pressure set point at the set junction + :type p_setpoint_bar: float :param mdot_flow_kg_per_s: Constant mass flow, which is transported through the pump :type mdot_flow_kg_per_s: float :param t_flow_k: Temperature set point at the flow junction @@ -829,11 +848,11 @@ def create_circ_pump_const_mass_flow(net, return_junction, flow_junction, p_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) + type = _auto_ext_grid_type(p_setpoint_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)} + "p_setpoint_bar": p_setpoint_bar, "t_flow_k": t_flow_k, "mdot_flow_kg_per_s": mdot_flow_kg_per_s, + "setpoint":"flow", "type": type, "in_service": bool(in_service)} _set_entries(net, "circ_pump_mass", index, **v, **kwargs) return index diff --git a/src/pandapipes/io/convert_format.py b/src/pandapipes/io/convert_format.py index 07136dc08..86cd625ed 100644 --- a/src/pandapipes/io/convert_format.py +++ b/src/pandapipes/io/convert_format.py @@ -48,9 +48,9 @@ def _rename_columns(net): for comp in [CirculationPumpMass, CirculationPumpPressure]: cp_tbl = comp.table_name() if cp_tbl in net: - 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"] + old_cols = ["from_junction", "to_junction", "mdot_kg_per_s", "p_bar","p_flow_bar", "t_k"] + new_cols = list(comp.from_to_node_cols()) + ["mdot_flow_kg_per_s", + "p_setpoint_bar","p_setpoint_bar","t_flow_k"] for old_col, new_col in list(zip(old_cols, new_cols)): if old_col in net[cp_tbl].columns and new_col not in net[cp_tbl].columns: net[cp_tbl].rename(columns={old_col: new_col}, inplace=True) @@ -64,7 +64,12 @@ def _add_missing_columns(net): net.controller.at[ctrl.name, 'initial_run'] = ctrl['object'].initial_run else: net.controller.at[ctrl.name, 'initial_run'] = ctrl['object'].initial_pipeflow - + if "circ_pump_pressure" in net: + if "setpoint" not in net.circ_pump_pressure: + net.circ_pump_pressure.insert(6, 'setpoint', "flow") + if "circ_pump_mass" in net: #Why are circ pumps in some versions existing and in some not? + if "setpoint" not in net.circ_pump_mass: + net.circ_pump_mass.insert(6, 'setpoint', "flow") def _rename_attributes(net): if "std_type" in net and "std_types" not in net: 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..c6860f4df 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 @@ -104,12 +104,12 @@ def release_control_test_network(max_iter_hyd, save=False): # 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, + net, return_junction=3, flow_junction=4, p_setpoint_bar=6, mdot_flow_kg_per_s=1, t_flow_k=290, name="Circ. Pump Mass", index=None, in_service=True, type="pt") # 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, + net, return_junction=11, flow_junction=5, p_setpoint_bar=5, plift_bar=2, t_flow_k=290, name="Circ. Pump Pressure", index=None, in_service=True, type="pt") # heat exchanger @@ -222,12 +222,12 @@ def release_control_test_network_water(max_iter_hyd, save=False): # 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=0.2, t_flow_k=290, + net, return_junction=3, flow_junction=4, p_setpoint_bar=6, mdot_flow_kg_per_s=0.2, t_flow_k=290, name="Circ. Pump Mass", index=None, in_service=True, type="pt") # 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, + net, return_junction=11, flow_junction=5, p_setpoint_bar=5, plift_bar=2, t_flow_k=290, name="Circ. Pump Pressure", index=None, in_service=True, type="pt") # heat exchanger 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..d823476af 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 @@ -59,3 +59,112 @@ def test_circulation_pump_constant_pressure(use_numba): assert np.all(v_diff < 0.01) assert np.all(mdot_diff < 0.01) assert np.all(deltap_diff < 0.01) + +@pytest.mark.parametrize("use_numba", [True, False]) +def test_circ_pump_pressure_return_flow(use_numba): + net = pandapipes.create_empty_network(fluid="water") + + j0 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 0") + j1 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 1") + j2 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 2") + j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 3") + + pandapipes.create_circ_pump_const_pressure(net, return_junction=j3, flow_junction=j0, p_setpoint_bar=7.5, + plift_bar=5, setpoint='return', t_flow_k=273.15 + 35) + + pandapipes.create_heat_exchanger(net, from_junction=j1, to_junction=j2, diameter_m=200e-3, qext_w=100000) + + pandapipes.create_pipe_from_parameters(net, from_junction=j0, to_junction=j1, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + pandapipes.create_pipe_from_parameters(net, from_junction=j2, to_junction=j3, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + max_iter_hyd = 10 if use_numba else 10 + 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) + data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure_return_flow.csv"), sep=';') + + res_junction = net.res_junction + res_pipe = net.res_pipe.v_mean_m_per_s.values + res_pump = net.res_circ_pump_pressure + + p_diff = np.abs(1 - res_junction.p_bar.values / data['p'].dropna().values) + t_diff = np.abs(1 - res_junction.t_k.values / data['t'].dropna().values) + v_diff = np.abs(1 - res_pipe / data['v'].dropna().values) + mdot_diff = np.abs(1 - res_pump['mdot_flow_kg_per_s'].values / data['mdot'].dropna().values) + deltap_diff = np.abs(1 - res_pump['deltap_bar'].values / data['deltap'].dropna().values) + + assert np.all(p_diff < 0.01) + assert np.all(t_diff < 0.01) + assert np.all(v_diff < 0.01) + assert np.all(mdot_diff < 0.01) + assert np.all(deltap_diff < 0.01) + +@pytest.mark.parametrize("use_numba", [True, False]) +def test_circ_pump_pressure_return_and_flow_setpoint(use_numba): + """ + :param use_numba: + :type use_numba: + :return: + :rtype: + """ + net = pandapipes.create_empty_network(fluid="water") + #first closed loop + j0 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 0") + j1 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 1") + j2 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 2") + j3 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 3") + + pandapipes.create_circ_pump_const_pressure(net, return_junction=j3, flow_junction=j0, p_setpoint_bar=7.5, + plift_bar=5, setpoint='flow', t_flow_k=273.15 + 35) + + + pandapipes.create_heat_exchanger(net, from_junction=j1, to_junction=j2, diameter_m=200e-3, qext_w=100000) + + pandapipes.create_pipe_from_parameters(net, from_junction=j0, to_junction=j1, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + pandapipes.create_pipe_from_parameters(net, from_junction=j2, to_junction=j3, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + # second closed loop + j4 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 0") + j5 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 1") + j6 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 2") + j7 = pandapipes.create_junction(net, pn_bar=5, tfluid_k=293.15, name="junction 3") + + pandapipes.create_circ_pump_const_pressure(net, return_junction=j7, flow_junction=j4, p_setpoint_bar=5, + plift_bar=5, setpoint='return', t_flow_k=273.15 + 35) + + + pandapipes.create_heat_exchanger(net, from_junction=j5, to_junction=j6, diameter_m=200e-3, qext_w=100000) + + pandapipes.create_pipe_from_parameters(net, from_junction=j4, to_junction=j5, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + pandapipes.create_pipe_from_parameters(net, from_junction=j6, to_junction=j7, length_km=1, + diameter_m=200e-3, k_mm=.1, alpha_w_per_m2k=10, sections=5, text_k=283) + + max_iter_hyd = 10 if use_numba else 10 + 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) + + data = pd.read_csv(os.path.join(data_path, "test_circ_pump_pressure_return_and_flow_setpoint.csv"), sep=';') + + res_junction = net.res_junction + res_pipe = net.res_pipe.v_mean_m_per_s.values + res_pump = net.res_circ_pump_pressure + + p_diff = np.abs(1 - res_junction.p_bar.values / data['p'].dropna().values) + t_diff = np.abs(1 - res_junction.t_k.values / data['t'].dropna().values) + v_diff = np.abs(1 - res_pipe / data['v'].dropna().values) + mdot_diff = np.abs(1 - res_pump['mdot_flow_kg_per_s'].values / data['mdot'].dropna().values) + deltap_diff = np.abs(1 - res_pump['deltap_bar'].values / data['deltap'].dropna().values) + + assert np.all(p_diff < 0.01) + assert np.all(t_diff < 0.01) + assert np.all(v_diff < 0.01) + assert np.all(mdot_diff < 0.01) + assert np.all(deltap_diff < 0.01) \ No newline at end of file diff --git a/src/pandapipes/test/data/test_circ_pump_pressure_return_and_flow_setpoint.csv b/src/pandapipes/test/data/test_circ_pump_pressure_return_and_flow_setpoint.csv new file mode 100644 index 000000000..50a8b9157 --- /dev/null +++ b/src/pandapipes/test/data/test_circ_pump_pressure_return_and_flow_setpoint.csv @@ -0,0 +1,9 @@ +p;t;v;mdot;deltap +7.50000;308.15000;2.43860;76.60166;5.00000 +5.00031;307.66127;2.43860;76.60166;5.00000 +5.00031;307.34896;2.43860 +2.50000;306.87580;2.43860 +10.00000;308.15000 +7.50031;307.66127 +7.50031;307.34896 +5.00000;306.87580 diff --git a/src/pandapipes/test/data/test_circ_pump_pressure_return_flow.csv b/src/pandapipes/test/data/test_circ_pump_pressure_return_flow.csv new file mode 100644 index 000000000..2ca4e890a --- /dev/null +++ b/src/pandapipes/test/data/test_circ_pump_pressure_return_flow.csv @@ -0,0 +1,6 @@ +p;t;v;mdot;deltap +12.50000;308.15000;2.43860;76.60166;5 +10.00031;307.66127;2.43860 +10.00031;307.34896 +7.50000;306.87580 + diff --git a/tutorials/circular_flow_in_a_district_heating_grid.ipynb b/tutorials/circular_flow_in_a_district_heating_grid.ipynb index a06e23669..61a7c06ae 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=j3, flow_junction=j0, p_flow_bar=5,\n", + "pp.create_circ_pump_const_mass_flow(net, return_junction=j3, flow_junction=j0, p_setpoint_bar=5,\n", " mdot_flow_kg_per_s=20, t_flow_k=273.15+35)" ] },