diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 752e62fa..16d2932c 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 diff --git a/src/pandapipes/component_models/component_toolbox.py b/src/pandapipes/component_models/component_toolbox.py index b90a1fba..fd598c5c 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 fbcf909d..033a272c 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 6228abea..40f22de1 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 cbcaef46..d0eeba78 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/pipe_component.py b/src/pandapipes/component_models/pipe_component.py index 98d6232a..0dcf95ab 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/component_models/pressure_control_component.py b/src/pandapipes/component_models/pressure_control_component.py index b2e5b3de..4b5d32b4 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 eeaa8938..aed85dfd 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 b8840336..75a7b7bf 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 311a84d9..a028cd17 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 6a4b616a..4857f5b1 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, 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} + 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) @@ -62,9 +59,13 @@ 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], \ - branch_pit[:, LAMBDA], node_pit[from_nodes, PINIT], node_pit[to_nodes, PINIT], \ - branch_pit[:, PL] + t_outlet = branch_pit[:, TOUTINIT] + 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): @@ -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] @@ -175,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 @@ -212,6 +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 + if len(res_branch) > 0: + use_numba = get_net_option(net, "use_numba") + _, 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,