Is your feature request related to a problem? Please describe.
When running the following code snippet:
from pandapipes.networks.simple_heat_transfer_networks import heat_transfer_delta
import numpy as np
net = heat_transfer_delta()
net.pipe.at[0, "sections"] = np.nan
pandapipes.pipeflow(net)
The following exception is raised:
/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/pandapipes/component_models/pipe_component.py:73: RuntimeWarning: invalid value encountered in cast
return np.array(net[cls.table_name()].sections.values).astype(np.int32)
/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/pandapipes/component_models/pipe_component.py:73: RuntimeWarning: invalid value encountered in cast
return np.array(net[cls.table_name()].sections.values).astype(np.int32)
Traceback (most recent call last):
File "/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3747, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-86-d69b2c49678a>", line 1, in <module>
pandapipes.pipeflow(net)
File "/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/pandapipes/pipeflow.py", line 70, in pipeflow
initialize_pit(net)
File "/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/pandapipes/pf/pipeflow_setup.py", line 388, in initialize_pit
pit = create_empty_pit(net)
^^^^^^^^^^^^^^^^^^^^^
File "/home/daniel/workspace/pack/.venv/lib/python3.12/site-packages/pandapipes/pf/pipeflow_setup.py", line 429, in create_empty_pit
pit = {"node": np.empty((node_length, node_cols), dtype=np.float64),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
numpy._core._exceptions._ArrayMemoryError: Unable to allocate 288. GiB for an array with shape (2147483658, 18) and data type float64
Which is extremely confusing for a user who doesn't know where this might come from.
Describe the solution you'd like
This issue does not appear exactly pipeflow related and is hard to understand. The issue lies in the BranchWOInternals component:
@classmethod
def create_branch_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current_start, current_table, internals):
"""
Function which creates branch lookups.
:param net: The pandapipes network
:type net: pandapipesNet
:param ft_lookups:
:type ft_lookups:
:param table_lookup:
:type table_lookup:
:param idx_lookups:
:type idx_lookups:
:param current_start:
:type current_start:
:param current_table:
:type current_table:
:param internals:
:type internals:
:return:
:rtype:
"""
internal_branches = cls.get_internal_branch_number(net)
internal_branches_num = int(np.sum(internal_branches))
...
The internal_branches_num becomes an extremely large number. I would add a check here and either throw a clear exception or replace all nans with 1 with at least a logger warning.
Describe alternatives you've considered
It could be left to the user or an external function to identify this problem, but this might lead to machines hanging up, just due to a small input error. I would prefer a clear exception over a silent warning with assumed value of 1, but either seems mandatory.
Is your feature request related to a problem? Please describe.
When running the following code snippet:
The following exception is raised:
Which is extremely confusing for a user who doesn't know where this might come from.
Describe the solution you'd like
This issue does not appear exactly pipeflow related and is hard to understand. The issue lies in the BranchWOInternals component:
The internal_branches_num becomes an extremely large number. I would add a check here and either throw a clear exception or replace all nans with 1 with at least a logger warning.
Describe alternatives you've considered
It could be left to the user or an external function to identify this problem, but this might lead to machines hanging up, just due to a small input error. I would prefer a clear exception over a silent warning with assumed value of 1, but either seems mandatory.