Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: result extraction for incompressible media now based on real density #640

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 3 additions & 4 deletions src/pandapipes/component_models/component_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,18 @@ 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")]

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"),
("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

Expand Down
2 changes: 1 addition & 1 deletion src/pandapipes/component_models/flow_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/pandapipes/component_models/heat_consumer_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions src/pandapipes/component_models/pipe_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/pandapipes/component_models/pressure_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
9 changes: 5 additions & 4 deletions src/pandapipes/component_models/pump_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion src/pandapipes/component_models/valve_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/pandapipes/converter/stanet/preparing_steps.py
dlohmeier marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 7 additions & 3 deletions src/pandapipes/pf/result_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(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], \
branch_pit[:, PL]
Expand Down
Loading
Loading